private void buttonFacebookLogin_Click(object sender, EventArgs e) { var appID = "1438195436291282"; var loginDialog = new FacebookLoginDialog(appID, ExtendedPermissions); loginDialog.ShowDialog(this); if (loginDialog.FacebookOAuthResult != null) { Properties.Settings.Default.FacebookToken = loginDialog.FacebookOAuthResult.AccessToken; } updateLoginLabel(); }
private void FacebookStart() { // open the Facebook Login Dialog and ask for user permissions. var fbLoginDlg = new FacebookLoginDialog("1883803658504479", "public_profile,publish_actions"); fbLoginDlg.ShowDialog(); // The user has taken action, either allowed/denied or cancelled the authorization, // which can be known by looking at the dialogs FacebookOAuthResult property. // Depending on the result take appropriate actions. TakeLoggedInAction(fbLoginDlg.FacebookOAuthResult); }
internal static bool LoginToFacebook() { const string appId = "228803620534906"; string extendedPermissions = "publish_actions,email"; var fbLoginDialog = new FacebookLoginDialog(appId, extendedPermissions); fbLoginDialog.ShowDialog(); var facebookOAuthResult = fbLoginDialog.FacebookOAuthResult; if (facebookOAuthResult != null) { if (facebookOAuthResult.IsSuccess) { Properties.Settings.Default.FacebookAccessToken = facebookOAuthResult.AccessToken; Properties.Settings.Default.FacebookAccessTokenExpiration = facebookOAuthResult.Expires; Properties.Settings.Default.Save(); Logger.Info("Logged in to Facebook with access token " + Properties.Settings.Default.FacebookAccessToken); Logger.Info("Access token expires at " + Properties.Settings.Default.FacebookAccessTokenExpiration); try { var captureEmailAddressWorker = new BackgroundWorker(); captureEmailAddressWorker.DoWork += new DoWorkEventHandler(captureEmailAddressWorker_DoWork); captureEmailAddressWorker.RunWorkerAsync(); } catch { } return true; } else { Properties.Settings.Default.FacebookAccessToken = ""; MessageBox.Show("Ah bummer -- we weren't able to sign you in to Facebook." + Environment.NewLine + Environment.NewLine + "Here's what Facebook told us: " + facebookOAuthResult.ErrorDescription, "Error logging in", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error signing into Facebook: " + facebookOAuthResult.Error + " - " + facebookOAuthResult.ErrorDescription); return false; } } else return false; }