Пример #1
0
        //private void TempCode()
        //{
        //    var app = new FacebookApp();
        //    dynamic me = app.Get("me");
        //    string firstName = me.first_name;
        //    string lastName = me.last_name;
        //    string email = me.email;
        //}
        //
        // GET: /Account/LogOn/
        public ActionResult LogOn(string returnUrl)
        {
            //TempCode();

            // MLW TODO Temp to try to fix case when user cookie has expired. Consider both Ajax and non-Ajax cases.
            if (returnUrl != null)
            {
                FormsAuthentication.SignOut();

                // This results in the html being shown in a message box for the Ajax requests (Eg. delete event)
                //return RedirectToAction("Index", "Home");  // Enough of a clue that they need to log back in?

                // The following shows a messagebox with the following for ajax requests(?)
                return Content("You have been logged out due to inaction.\r\n Please log back in.");
                // Seemed to return that as the entire content instead...Confusing.

            }

            var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
            oAuthClient.RedirectUri = new Uri(redirectUrl);

            // See http://developers.facebook.com/docs/reference/dialogs/oauth/

            var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", returnUrl }, {"scope", "publish_stream"} });

            SMap.GetLogger().Application("Log on attempt to: " + loginUri.AbsoluteUri + " based on redirect url " + redirectUrl);

            return Redirect(loginUri.AbsoluteUri);
        }
Пример #2
0
 /// <summary>
 /// Get Application Access Token
 /// </summary>
 /// <returns></returns>
 public string GetAppAccessToken()
 {
     var fb = new FacebookOAuthClient { AppId = "340791049284352", AppSecret = "c46526d851aaf7dd547a63ae332d3e49" };
     dynamic result = fb.GetApplicationAccessToken();
     var appAccessToken = result.access_token;
     return appAccessToken.ToString();
 }
Пример #3
0
 //
 // GET: /Account/LogOff/
 public ActionResult LogOff()
 {
     FormsAuthentication.SignOut();
     var oAuthClient = new FacebookOAuthClient {RedirectUri = new Uri(LogoffUrl)};
     var logoutUrl = oAuthClient.GetLogoutUrl();
     return Redirect(logoutUrl.AbsoluteUri);
 }
        public FacebookLoginDialog(string appId, string extendedPermissions)
        {
            if (string.IsNullOrEmpty(appId))
                throw new ArgumentNullException("appId");

            // Make sure to set the app id.
            var oauthClient = new FacebookOAuthClient { AppId = appId };

            IDictionary<string, object> loginParameters = new Dictionary<string, object>();

            // The requested response: an access token (token), an authorization code (code), or both (code token).
            loginParameters["response_type"] = "token";

            // list of additional display modes can be found at http://developers.facebook.com/docs/reference/dialogs/#display
            loginParameters["display"] = "popup";

            // add the 'scope' parameter only if we have extendedPermissions.
            if (!string.IsNullOrEmpty(extendedPermissions))
            {
                // A comma-delimited list of permissions
                loginParameters["scope"] = extendedPermissions;
            }

            // when the Form is loaded navigate to the login url.
            _loginUrl = oauthClient.GetLoginUrl(loginParameters);

            InitializeComponent();
        }
Пример #5
0
        public FacebookForm()
        {
            InitializeComponent();

            string _appID = Properties.Settings.Default.fb_AppKey;
            string _appSec = Properties.Settings.Default.fb_AppSec;
            string[] extendedPermissions = new[] { "publish_stream", "offline_access" };

            var oauth = new FacebookOAuthClient { AppId = _appID, AppSecret = _appSec };

            var parameters = new Dictionary<string, object>
                    {
                        { "response_type", "token" },
                        { "display", "popup" }
                    };

            if (extendedPermissions != null && extendedPermissions.Length > 0)
            {
                var scope = new StringBuilder();
                scope.Append(string.Join(",", extendedPermissions));
                parameters["scope"] = scope.ToString();
            }

            var loginUrl = oauth.GetLoginUrl(parameters);
            webBrowser1.Navigate(loginUrl);
        }
        public FacebookLoginDialog(string appId, string[] extendedPermissions, bool logout)
        {
            var oauth = new FacebookOAuthClient { AppId = appId };

            var loginParameters = new Dictionary<string, object>
                    {
                        { "response_type", "token" },
                        { "display", "popup" }
                    };

            if (extendedPermissions != null && extendedPermissions.Length > 0)
            {
                var scope = new StringBuilder();
                scope.Append(string.Join(",", extendedPermissions));
                loginParameters["scope"] = scope.ToString();
            }

            var loginUrl = oauth.GetLoginUrl(loginParameters);

            if (logout)
            {
                var logoutParameters = new Dictionary<string, object>
                    {
                        { "next", loginUrl }
                    };
            }
            else
            {
                this.navigateUrl = loginUrl;
            }

            InitializeComponent();
        }
        /// <summary>
        /// Get FacebookOAuthClient.
        /// </summary>
        void MainPage_Loaded()
        {
            using (DbStorage fbdb = new DbStorage(strConnectionString))
            {
                IQueryable<Db> fbQuery = from db in fbdb.user select db;
                Db ac = fbQuery.FirstOrDefault();
                if(ac == null){
                    string appId = "YOUR FACEBOOK APP ID";
                    string[] extendedPermissions = new[] { "publish_stream"};

                    var oauth = new FacebookOAuthClient { AppId = appId };
                    var parameters = new Dictionary<string, object>
                            {
                               { "response_type", "token" },
                                { "display", "touch" }
                            };
                    if (extendedPermissions != null && extendedPermissions.Length > 0)
                    {
                        var scope = new StringBuilder();
                        scope.Append(string.Join(",", extendedPermissions));
                        parameters["scope"] = scope.ToString();
                    }
                    var loginUrl = oauth.GetLoginUrl(parameters);
                    //Add webBrowser to the contentPanel
                    _webBrowser.Navigate(loginUrl);
                    ContentPanel.Children.Add(_webBrowser);
                    _webBrowser.Navigated += webBrowser_Navigated;
                    //Open the facebook login page into the browser
           
            }
        }
        }
Пример #8
0
        public static void handleOAuthResult(HttpRequest request, int id)
        {
            FacebookOAuthResult oAuthResult;
            if (FacebookOAuthResult.TryParse(request.Url, out oAuthResult))
            {
                if (oAuthResult.IsSuccess)
                {
                    string code = request.Params["code"];
                    FacebookOAuthClient oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
                    oAuthClient.RedirectUri = new Uri(redirectUrl + "/" + id + "/");
                    oAuthClient.AppId = ConfigurationManager.AppSettings["Facebook_API_Key"];
                    oAuthClient.AppSecret = ConfigurationManager.AppSettings["Facebook_API_Secret"];
                    dynamic tokenResult = oAuthClient.ExchangeCodeForAccessToken(code);

                    string accessToken = tokenResult.access_token;

                    FacebookClient facebookClient = new FacebookClient(accessToken);
                    dynamic me = facebookClient.Get("me");
                    long facebookId = Convert.ToInt64(me.id);

                    var facebookService = new FacebookService();
                    FacebookUser fbUser = facebookService.AddFacebookUser(facebookId, accessToken, me.name, me.gender);
                    HttpContext.Current.Session["FBUser"] = fbUser;
                    var _publishedArticleService = new PublishedArticleService();
                    var article = _publishedArticleService.GetPublishedArticle(id);
                    System.Web.HttpContext.Current.Response.Redirect("/Blog/Details/" + article.headline.Replace(" ", "_") + "/" + article.articleId + "/");
                }
            }
        }
Пример #9
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            //List of all the permissions you want to have access to
            //You can get the list of possiblities from here http://developers.facebook.com/tools/explorer/
            string[] extendedPermissions = new[] { "email", "publish_stream", "offline_access", "user_groups" };

            var oauth = new FacebookOAuthClient { AppId = FacebookHelpers.appId };
            //Telling the Facebook that we want token as response
            //and we are using touch enabled device
            var parameters = new Dictionary<string, object>
                    {
                        { "response_type", "token" },
                        { "display", "touch" }
                    };
            //If there's extended permissions build the string and set it up
            if (extendedPermissions != null && extendedPermissions.Length > 0)
            {
                var scope = new StringBuilder();
                scope.Append(string.Join(",", extendedPermissions));
                parameters["scope"] = scope.ToString();
            }
            //Create the login url
            var loginUrl = oauth.GetLoginUrl(parameters);
            //Add webBrowser to the contentPanel
            ContentPanel.Children.Add(_webBrowser);
            _webBrowser.Navigated += webBrowser_Navigated;
            //Open the facebook login page into the browser
            _webBrowser.Navigate(loginUrl);
        }
Пример #10
0
 /// <summary>
 /// Logon to application
 /// </summary>
 public ActionResult LogOn(string returnUrl)
 {
     var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
     oAuthClient.RedirectUri = new Uri(redirectUrl);
     var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", returnUrl } });
     return Redirect(loginUri.AbsoluteUri);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            var url = HttpContext.Current.Request.Url;
            FacebookOAuthResult oauthResult;

            var oauthClient = new FacebookOAuthClient { AppId = AppId, AppSecret = AppSecret, RedirectUri = new Uri(_silverlightFacebookCallback) };

            if (oauthClient.TryParseResult(url, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    var result = (IDictionary<string, object>)oauthClient.ExchangeCodeForAccessToken(oauthResult.Code);
                    AccessToken = result["access_token"].ToString();
                    Label1.Text = AccessToken;
                }
                else
                {
                    ErrorDescription = oauthResult.ErrorDescription;
                }

                Response.Cache.SetCacheability(HttpCacheability.NoCache);
            }
            else
            {
                Response.Redirect("~/");
            }
        }
Пример #12
0
 public ActionResult FBLogOn(string returnUrl)
 {
     var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
     oAuthClient.RedirectUri = new Uri(HttpContext.Request.Url,Url.Action("FBOAuth","Auth"));
     var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", returnUrl }, { "scope", "user_about_me,user_activities,user_education_history,user_hometown,user_interests,user_location,user_likes,user_religion_politics,user_work_history" } });
     return Redirect(loginUri.AbsoluteUri);
 }
Пример #13
0
 //
 // GET: /Account/LogOff/
 public ActionResult LogOff()
 {
     FormsAuthentication.SignOut();
     var oAuthClient = new FacebookOAuthClient();
     oAuthClient.RedirectUri = new Uri(ConfigurationManager.AppSettings["LogoffUrl"]);
     var logoutUrl = oAuthClient.GetLogoutUrl();
     return Redirect(logoutUrl.AbsoluteUri);
 }
Пример #14
0
        public ActionResult OAuth(string returnUrl)
        {
            var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
            oAuthClient.RedirectUri = new Uri(redirectUrl);

            var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", "state_" }, { "scope", "offline_access,manage_pages,publish_stream" } });
            return Redirect(loginUri.AbsoluteUri);
        }
Пример #15
0
 //
 // GET: /Account/LogOn/
 public ActionResult LogOn(string returnUrl)
 {
     string redirectUrl = "http://" + Request.Url.Host + "/Account/OAuth/";
     var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
     oAuthClient.RedirectUri = new Uri(redirectUrl);
     var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", returnUrl } });
     return Redirect(loginUri.AbsoluteUri);
 }
Пример #16
0
 public static string GetFacebookLoginLink(string host, LoginMethod method)
 {
     var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
     string redirectUrl = String.Format("{0}/{1}?method={2}", host, "login.aspx", EnumHelper.EnumToString(method));
     oAuthClient.RedirectUri = new Uri(redirectUrl);
     var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", redirectUrl } });
     return loginUri.AbsoluteUri;
 }
        public void ItShouldThrowInvalidOperationException()
        {
            var oauth = new FacebookOAuthClient();

            var parameters = new Dictionary<string, object>();
            parameters["client_id"] = "dummy client id";
            parameters["redirect_uri"] = null;

            Assert.Throws<ArgumentException>(() => oauth.GetLoginUrl(parameters));
        }
Пример #18
0
        public ActionResult Login(string id, string returnUrl)
        {
            if (id != null)
            {
                Session["PersonTryingToLogin"] = PersonDataAccessor.FetchPersonFromPublicId(id);
            }

            var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
            oAuthClient.RedirectUri = new Uri(ConfigurationManager.AppSettings["RedirectUrl"]);
            var loginUri = oAuthClient.GetLoginUrl(new Dictionary<string, object> { { "state", returnUrl } });
            return Redirect(loginUri.AbsoluteUri + "&scope=user_birthday,email");
        }
Пример #19
0
    private string GetFbLoginUrl()
    {
        string callBackUrl = Settings.Url + "/CallbackFB.aspx";
        callBackUrl += "?ReturnUrl=" + StringUtils.ToHexString(HttpUtility.UrlEncode("/Contact.aspx"));//facebook sdk does not like special characters

        FacebookOAuthClient oauth = new FacebookOAuthClient(GlobalObjects.FBApp);
        oauth.RedirectUri = new Uri(callBackUrl);

        Dictionary<string, object> dict = new Dictionary<string, object>();
        dict.Add("scope", "email");
        return oauth.GetLoginUrl(dict).ToString();
    }
Пример #20
0
        public ActionResult Callback(string code, string state)
        {
            FacebookOAuthResult oauthResult;
            if (FacebookOAuthResult.TryParse(Request.Url, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
                    oAuthClient.RedirectUri = new Uri(redirectUrl);
                    dynamic tokenResult = oAuthClient.ExchangeCodeForAccessToken(code);
                    string accessToken = tokenResult.access_token;

                    DateTime expiresOn = DateTime.MaxValue;

                    FacebookClient fbClient = new FacebookClient(accessToken);
                    dynamic me = fbClient.Get("me?fields=id,name");
                    long facebookId = Convert.ToInt64(me.id);

                    var account = Accounts.Get().Where(Accounts.Columns.ForeignID, Actions.Equal, facebookId).SelectOne();
                    if (account == null)
                    {
                        account = new Account { FBKey = accessToken, Name = me.name, ForeignID = facebookId.ToString() };
                        account.Insert();
                    }
                    else
                    {
                        account.FBKey = accessToken;
                        account.Name = me.name;
                        account.Update();
                    }
                    dynamic pages = fbClient.Get("me/accounts");
                    foreach (var p in pages.data)
                    {
                        FBPage page = FBPages.Get().Where(FBPages.Columns.ForeignID, Actions.Equal, p.id).SelectOne();
                        if (page == null)
                        {
                            page = new FBPage { ForeignID = p.id, Name = p.name, Token = p.access_token };
                            page.Insert();
                        }
                        else
                        {
                            page.Name = p.name;
                            page.Token = p.access_token;
                            page.Update();
                        }
                    }

                    ViewBag.Name = account.Name;
                }
            }

            return View();
        }
        public void GivenParametersAsCodeTokenThenShouldEncodeCorrectly()
        {
            var oauth = new FacebookOAuthClient();

            var loginParameters = new Dictionary<string, object>();
            loginParameters["client_id"] = "appid";
            loginParameters["client_secret"] = "clientsecret";
            loginParameters["response_type"] = "code token";

            var loginUrl = oauth.GetLoginUrl(loginParameters);

            Assert.Equal("http://www.facebook.com/dialog/oauth/?client_id=appid&client_secret=clientsecret&response_type=code%20token&redirect_uri=http%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html",
                loginUrl.AbsoluteUri);
        }
Пример #22
0
        public ActionResult OAuth(string code, string state)
        {
            FacebookOAuthResult oauthResult;
            if (FacebookOAuthResult.TryParse(Request.Url, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
                    oAuthClient.RedirectUri = new Uri(redirectUrl);
                    dynamic tokenResult = oAuthClient.ExchangeCodeForAccessToken(code);
                    string accessToken = tokenResult.access_token;

                    DateTime expiresOn = DateTime.MaxValue;

                    if (tokenResult.ContainsKey("expires"))
                    {
                        DateTimeConvertor.FromUnixTime(tokenResult.expires);
                    }

                    FacebookClient fbClient = new FacebookClient(accessToken);
                    dynamic me = fbClient.Get("me?fields=id,name");
                    long facebookId = Convert.ToInt64(me.id);
                    Auth(facebookId.ToString());

                    //InMemoryUserStore.Add(new FacebookUser
                    //{
                    //    AccessToken = accessToken,
                    //    Expires = expiresOn,
                    //    FacebookId = facebookId,
                    //    Name = (string)me.name,
                    //});

                    //FormsAuthentication.SetAuthCookie(facebookId.ToString(), false);

                    // prevent open redirection attack by checking if the url is local.
                    //if (Url.IsLocalUrl(state))
                    //{
                    //    return Redirect(state);
                    //}
                    //else
                    //{
                    //    return RedirectToAction("Index", "Home");
                    //}
                    return RedirectToAction("Index", "Home");

                }
            }

            return RedirectToAction("Index", "Home");
        }
Пример #23
0
    private string GetFbLoginUrl()
    {
        string callBackUrl = Settings.Url + "/CallbackFB.aspx";
        string returnUrl = Request.QueryString["ReturnUrl"];
        if (!String.IsNullOrEmpty(returnUrl))
          callBackUrl += "?ReturnUrl=" + StringUtils.ToHexString(returnUrl);//facebook sdk does not like special characters

        FacebookOAuthClient oauth = new FacebookOAuthClient(GlobalObjects.FBApp);
        oauth.RedirectUri = new Uri(callBackUrl);

        Dictionary<string, object> dict = new Dictionary<string, object>();
        dict.Add("scope", "email");
        return oauth.GetLoginUrl(dict).ToString();
    }
Пример #24
0
 //
 // GET: /Account/LogOff/
 public ActionResult LogOff()
 {
     FormsAuthentication.SignOut();
     var oAuthClient = new FacebookOAuthClient();
     if (IsDebug)
     {
         oAuthClient.RedirectUri = new Uri(logoffUrlDebug);
     }
     else
     {
         oAuthClient.RedirectUri = new Uri(logoffUrl);
     }
     //var logoutUrl = oAuthClient.GetLogoutUrl();
     //return Redirect(logoutUrl.AbsoluteUri);
     return Redirect("http://www.google.es");
 }
        public void ItExceptionMessageShouldBeClientIdRequired()
        {
            var oauth = new FacebookOAuthClient();
            Exception exception = null;

            try
            {
                oauth.GetLoginUrl(null);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.Equal("client_id required.", exception.Message);
        }
        public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
        {
            var builder = new UriBuilder(context.Request.GetUrlRewriter()) {Query = "p=" + context.Request["p"]};
            var oauth = new FacebookOAuthClient
            {
                AppId = KeyStorage.Get("facebookAppID"),
                AppSecret = KeyStorage.Get("facebookAppSecret"),
                RedirectUri = builder.Uri
            };
            FacebookOAuthResult result;
            if (FacebookOAuthResult.TryParse(context.Request.GetUrlRewriter(), out result))
            {
                if (result.IsSuccess)
                {
                    var accessToken = (Facebook.JsonObject)oauth.ExchangeCodeForAccessToken(result.Code);
                    var request = WebRequest.Create("https://graph.facebook.com/me?access_token=" + Uri.EscapeDataString((string)accessToken["access_token"]));
                    using (var response = request.GetResponse())
                    {
                        using (var responseStream = response.GetResponseStream())
                        {
                            var graph = FacebookGraph.Deserialize(responseStream);
                            var profile = ProfileFromFacebook(graph);
                            return profile;
                        }
                    }
                }
                return LoginProfile.FromError(new Exception(result.ErrorReason));
            }
            //Maybe we didn't query
            var extendedPermissions = new[] { "email", "user_about_me" };
            var parameters = new Dictionary<string, object>
                                 {
                                     { "display", "popup" }
                                 };

            if (extendedPermissions.Length > 0)
            {
                var scope = new StringBuilder();
                scope.Append(string.Join(",", extendedPermissions));
                parameters["scope"] = scope.ToString();
            }
            var loginUrl = oauth.GetLoginUrl(parameters);
            context.Response.Redirect(loginUrl.ToString());
            return LoginProfile.FromError(new Exception("Failed to login with facebook"));
        }
Пример #27
0
        public ActionResult FBOAuth(string code, string state)
        {
            FacebookOAuthResult oauthResult;
            if (FacebookOAuthResult.TryParse(Request.Url, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
                    oAuthClient.RedirectUri = new Uri(HttpContext.Request.Url, Url.Action("FBOAuth", "Auth"));
                    dynamic tokenResult = oAuthClient.ExchangeCodeForAccessToken(code);
                    string accessToken = tokenResult.access_token;

                    DateTime expiresOn = DateTime.MaxValue;

                    if (tokenResult.ContainsKey("expires"))
                    {
                        expiresOn = DateTimeConvertor.FromUnixTime(tokenResult.expires);
                    }

                    FacebookClient fbClient = new FacebookClient(accessToken);
                    dynamic me = fbClient.Get("me?fields=id,name");
                    long facebookId = Convert.ToInt64(me.id);

                    CurrentUser.FacebookToken = accessToken;
                    CurrentUser.FacebookExpiresDateTime = expiresOn;
                    CurrentUser.FacebookId = facebookId;
                    if (string.IsNullOrEmpty(CurrentUser.Name))
                        CurrentUser.Name = (string)me.name;

                    CurrentUser.Update();

                    // prevent open redirection attack by checking if the url is local.
                    if (Url.IsLocalUrl(state))
                    {
                        return Redirect(state);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
            }

            return RedirectToAction("Index", "Home");
        }
Пример #28
0
        public static string GetAccessToken(Uri requestUrl, string code)
        {
            FacebookOAuthResult oauthResult;
            if (FacebookOAuthResult.TryParse(requestUrl, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
                    string redirectUrl = String.Format("{0}://{1}/{2}?method=fblocal", requestUrl.Scheme, requestUrl.Host, "login.aspx");
                    oAuthClient.RedirectUri = new Uri(redirectUrl);
                    dynamic tokenResult = oAuthClient.ExchangeCodeForAccessToken(code);

                    FbContext.Current.AccessToken = tokenResult.access_token;
                    return tokenResult.access_token;
                }
            }

            throw new Exception();
        }
Пример #29
0
        public ActionResult OAuth(string code, string state)
        {
            string redirectUri = String.Empty;
            FacebookOAuthResult oauthResult;
            if (FacebookOAuthResult.TryParse(Request.Url, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
                    oAuthClient.RedirectUri = new Uri(Config.LoginRedirectUrl);
                    dynamic tokenResult = oAuthClient.ExchangeCodeForAccessToken(code);
                    string accessToken = tokenResult.access_token;

                    redirectUri = String.Format("{0}?method=fb&token={1}", Config.MembersLoginUrl, tokenResult.access_token);
                }
            }

            return new RedirectResult(redirectUri);
        }
Пример #30
0
        public FacebookWindow()
        {
            client = new FacebookOAuthClient { AppId = appId };
            parameters = new Dictionary<string, object> {
                { "response_type", "token" },
                { "display", "popup" }
            };

            if (extendedPermissions != null && extendedPermissions.Length > 0)
            {
                var scope = new StringBuilder();
                scope.Append(string.Join(",", extendedPermissions));
                parameters["scope"] = scope.ToString();
            }

            var loginUrl = client.GetLoginUrl(parameters);
            this.navigateUrl = loginUrl;

            InitializeComponent();
        }
Пример #31
0
 /// <summary>
 /// Gets the application access token asynchronously.
 /// </summary>
 /// <param name="facebookOAuthClient">The Facebook OAuth Client.</param>
 /// <returns>The task of the result.</returns>
 public static Task <object> GetApplicationAccessTokenTaskAsync(this FacebookOAuthClient facebookOAuthClient)
 {
     return(GetApplicationAccessTokenTaskAsync(facebookOAuthClient, null));
 }