Esempio n. 1
0
        void HandleCompleted(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs e)
        {
            base.DismissViewController(true, null);

            if (e.IsAuthenticated)
            {
                Hub.ApiClient.TokenProvider = e.Account;
            }

            _vm = new TimesheetsViewModel(Hub.ApiClient, Hub.Navigator);
            this.timesheetList.Bind(_vm.Timesheets, t => t.Name, _vm.TimesheetSelectedCommand);
            this.refreshTimesheets.Bind(_vm.Timesheets.RefreshCommand);
        }
Esempio n. 2
0
        private async void Oauth_Completed_GetAuthorizer(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs e)
        {
            _auth = _authSvc.GetAuthorizer(consumerKey,
                                           consumerSecret,
                                           e.Account.Properties["oauth_token"],
                                           e.Account.Properties["oauth_token_secret"]);

            await _loginStoreService.SetSecretsAsync(
                e.Account.Properties["oauth_token"],
                e.Account.Properties["oauth_token_secret"]
                );

            RefreshTimeline.ChangeCanExecute();

            RefreshTimeline.Execute(null);
        }
Esempio n. 3
0
        private void OnOAuth2Completed(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs e)
        {
            if (!e.IsAuthenticated)
            {
                // Non autenticato
                Debug.WriteLine("Not authenticated");
                LoggedIn?.Invoke(sender, new EventArgs());
                return;
            }

            Account = new OAuthAccountWrapper(e.Account);
            Debug.WriteLine("Authenticated");
            RememberDataAccess();

            LoggedIn?.Invoke(sender, new EventArgs());
        }
Esempio n. 4
0
        private void Authenticator_Completed(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs e)
        {
            if (e.IsAuthenticated)
            {
                var token = new
                {
                    TokenType   = e.Account.Properties["token_type"],
                    AccessToken = e.Account.Properties["access_token"]
                };

                ShowWishList();
            }
            else
            {
                //do something
            }
        }
Esempio n. 5
0
 public void Authentication_Completed(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs e)
 {
     return;
 }
Esempio n. 6
0
        public void Auth_Completed(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs ee)
        {
            string title = "Event Auth Completed";
            string msg   = null;

            DismissViewController
            (
                animated: true,
                completionHandler: () => { }
            );

            #if DEBUG
            string   d      = null;
            string[] values = ee?.Account?.Properties?.Select(x => x.Key + "=" + x.Value).ToArray();
            if (values != null)
            {
                d = string.Join("  ;  ", values);
            }
            msg = String.Format("TestProviderController.Auth_Completed {0}", d);
            System.Diagnostics.Debug.WriteLine(msg);
            #endif

            if (!ee.IsAuthenticated)
            {
                msg = "Not Authenticated";
            }
            else
            {
                try
                {
                    AccountStoreTests(sender, ee);
                    AccountStoreTestsAsync(sender, ee);
                }
                catch (Xamarin.Auth.AuthException exc)
                {
                    msg = exc.Message;
                    UIAlertView alert =
                        new UIAlertView
                        (
                            "Error - AccountStore Saving",
                            "AuthException = " + Environment.NewLine + msg,
                            null,
                            "OK",
                            null
                        );
                    alert.Show();
                    throw new Exception("AuthException", exc);
                }
                try
                {
                    //------------------------------------------------------------------
                    Account account = ee.Account;
                    string  token   = default(string);
                    if (null != account)
                    {
                        string token_name = default(string);
                        Type   t          = sender.GetType();
                        if (t == typeof(Xamarin.Auth.OAuth2Authenticator))
                        {
                            token_name = "access_token";
                            token      = account.Properties[token_name].ToString();
                        }
                        else if (t == typeof(Xamarin.Auth.OAuth1Authenticator))
                        {
                            token_name = "oauth_token";
                            token      = account.Properties[token_name].ToString();
                        }
                    }
                    //------------------------------------------------------------------

                    StringBuilder sb = new StringBuilder();
                    sb.Append("IsAuthenticated  = ").Append(ee.IsAuthenticated)
                    .Append(System.Environment.NewLine);
                    sb.Append("Account.UserName = "******"token            = ").Append(token)
                    .Append(System.Environment.NewLine);
                    msg = sb.ToString();
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                }
            }

            InvokeOnMainThread
            (
                () =>
            {
                // manipulate UI controls
                UIAlertView _error = new UIAlertView(title, msg, null, "Ok", null);
                _error.Show();
            }
            );

            return;
        }