コード例 #1
0
        public static string ToQueryString(this QueryStringParameter[] parameters)
        {
            string ret = "";

            for (int i = 0; i < parameters.Length; i++)
            {
                QueryStringParameter parm = parameters[i];
                ret += parm.Name + "=" + parm.Value;
                if (i != parameters.Length - 1)
                {
                    ret += "&";
                }
            }

            return(ret);
        }
コード例 #2
0
        public FacebookOAuthResult(ControllerContext context, params string[] permissions)
        {
            this.AuthorizationUrl = "https://graph.facebook.com/oauth/authorize?";

            string redirectUri = OAuthController.GetBaseRedirectUri(context);
            string clientId    = ConfigurationManager.AppSettings["FacebookClientId"];

            if (string.IsNullOrEmpty(clientId))
            {
                throw new ArgumentNullException("FacebookClientId was not found in the config file");
            }

            ClientId    = new QueryStringParameter("client_id", clientId);
            RedirectUri = new QueryStringParameter("redirect_uri", redirectUri);
            Scope       = permissions;
        }
コード例 #3
0
ファイル: OAuthController.cs プロジェクト: dekkerb115/Bam.Net
        private void SetUser()
        {
            using (WebClient client = new WebClient())
            {
                AccessTokenStore     store       = Providers.GetSessionProvider <AccessTokenStore>();
                QueryStringParameter accessToken = new QueryStringParameter("access_token", store.AccessToken);

                string  data        = client.DownloadString(string.Format("{0}{1}", CurrentUserUrl, accessToken.ToString()));
                JObject currentUser = JObject.Parse(data);
                currentUser.Add("auth_source", "Facebook");
                currentUser.Add("access_token", store.AccessToken);

                FacebookPrincipal principal = new FacebookPrincipal(currentUser, store.AccessToken);
                System.Web.HttpContext.Current.User = principal;
                Providers.SetSessionProvider <FacebookPrincipal>(principal, true);
                OnUserSet(currentUser);
            }
        }