Example #1
0
        public static async Task <string> LogIn()
        {
            string message = String.Empty;

            try
            {
                FacebookSession       session = new FacebookSession();
                FacebookSessionClient client  = new FacebookSessionClient(App.fbAppID);
                session = await client.LoginAsync(
                    "user_about_me," +
                    "friends_about_me," +
                    "publish_stream");

                App.isAuthenticated = true;
                App.fbToken         = session.AccessToken;
                App.fbUserID        = session.FacebookId;

                FacebookUser user = await Users.DownloadUserInfo(App.fbUserID);

                App.fbProfilePicture = user.Picture.data.url;
                App.fbProfileName    = user.Name;

                RenewToken();
                return("OK");
            }
            catch (InvalidOperationException e)
            {
                message = "Login failed! Exception details: " + e.Message;
                return(message);
            }
        }
Example #2
0
        private async Task Authenticate()
        {
            ShowProgressBar(true);

            FacebookSession       session;
            FacebookSessionClient fbclient = new FacebookSessionClient(FacebookAccount.App_Id);

            try
            {
                FacebookAccount.IsAuthenticated = true;

                session = await fbclient.LoginAsync(FacebookAccount.ExtendedPermissions);

                FacebookAccount.AccessToken = session.AccessToken;
                FacebookAccount.FacebookId  = session.FacebookId;

                FacebookAccount.IsConnected = true;

                NavigationService.Navigate(new Uri("/Views/Birthdays.xaml", UriKind.RelativeOrAbsolute));
            }
            catch (InvalidOperationException ioe)
            {
                MessageBox.Show("Login Failed! Exception: " + ioe.Message);
            }
            finally
            {
                ShowProgressBar(false);
            }
        }
Example #3
0
        private async Task LoginFacebook()
        {
            Deployment.Current.Dispatcher.BeginInvoke(async() =>
            {
                try
                {
                    session = await facebookSessionClient.LoginAsync("user_about_me,read_stream");

                    string js = "";

                    if (session != null)
                    {
                        accessToken    = session.AccessToken;
                        facebookId     = session.FacebookId;
                        facebookClient = new FacebookClient(accessToken);

                        js = String.Format("var e = document.createEvent('Events');e.initEvent('intel.xdk.facebook.login',true,true);e.success=true;e.token='';e.cancelled={0};document.dispatchEvent(e);", "false");
                    }
                    else
                    {
                        js = String.Format("var e = document.createEvent('Events');e.initEvent('intel.xdk.facebook.login',true,true);e.success=false;e.token='';e.cancelled={0};document.dispatchEvent(e);", "true");
                    }
                    InvokeCustomScript(new ScriptCallback("eval", new string[] { js }), true);
                }
                catch (Exception ex)
                {
                    string js = String.Format("var e = document.createEvent('Events');e.initEvent('intel.xdk.facebook.login',true,true);e.success=false;e.token='';e.cancelled={0};document.dispatchEvent(e);", "true");
                    InvokeCustomScript(new ScriptCallback("eval", new string[] { js }), true);
                }
            });
        }
Example #4
0
        private async Task AuthenticateFacebook()
        {
            try {
                FacebookSessionClient = new FacebookSessionClient(Constants.FacebookAppId);
                FacebookSession       = await FacebookSessionClient.LoginAsync("user_friends");

                AccessToken = FacebookSession.AccessToken;
                FacebookId  = FacebookSession.FacebookId;
                fbLoggedIn  = true;
                Debug.WriteLine("Facebook login succeeded, facebook ID: " + FacebookId);
            } catch (InvalidOperationException e) {
                MessageDialog dialog = new MessageDialog("Login failed! Exception details: " + e.Message);
                dialog.Commands.Add(new UICommand("Ok"));
                dialog.ShowAsync();
            }
        }
Example #5
0
            public static async Task <bool> canAuthenticate()
            {
                try
                {
                    FacebookSessionClient = new FacebookSessionClient(Main.FacebookAppId);
                    session = await FacebookSessionClient.LoginAsync("user_about_me,read_stream");

                    Main.AccessToken = session.AccessToken;
                    Main.FacebookId  = session.FacebookId;
                    return(true);
                }

                catch
                {
                    MessageBox.Show("No se pudo iniciar la sesion, intentalo de nuevo por favor");
                    session = new FacebookSession();
                    return(false);
                }
            }
Example #6
0
 private async Task PerformLogin()
 {
     session = await FacebookSessionClient.LoginAsync();
 }
Example #7
0
 public static async Task <FacebookSession> Authenticate()
 {
     return(await FacebookSessionClient.LoginAsync("user_about_me"));
 }