Esempio n. 1
0
        /// <summary>
        /// Removes a credential from the Credential Locker.
        /// </summary>
        /// <param name="resource">The resource for which the credentials are used.</param>
        /// <param name="userName">The user name that must be present in the credentials.</param>
        /// <param name="password">The password for the created credentials.</param>
        /// <exception cref="ArgumentNullException">Dispatched when <paramref name="resource"/>, <paramref name="userName"/> or
        /// <paramref name="password"/> is <c>Null</c>
        /// </exception>
        public bool Remove(string resource, string userName, string password)
        {
            if (string.IsNullOrEmpty(resource))
            {
                throw new ArgumentNullException(nameof(resource), "The argument is null");
            }
            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException(nameof(userName), "The argument is null");
            }
            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException(nameof(password), "The argument is null");
            }

            try
            {
                Account account = new Account {
                    Username = userName
                };
                account.Properties.Add(resource, password);
                vault.Delete(account, AppName);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 2
0
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var            authenticator = sender as OAuth2Authenticator;
            GoogleUserInfo user          = null;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }
            if (e.IsAuthenticated)
            {
                // If the user is authenticated, request their basic user data from Google
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    // Deserialize the data and store it in the account store
                    // The users email address will be used to identify data in SimpleDB
                    string userJson = await response.GetResponseTextAsync();

                    //await DisplayAlert("JSON", userJson, "OK"); debug
                    user = JsonConvert.DeserializeObject <GoogleUserInfo>(userJson);
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                CreateAccountGoogleAuth(user);
            }
        }
Esempio n. 3
0
        void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            if (e.IsAuthenticated)
            {
                if (this.account != null)
                {
                    store.Delete(this.account, ServiceId);
                }

                store.Save(account = e.Account, ServiceId);

                statusText.Text = "Authentication succeeded";
            }
            else
            {
                statusText.Text = "Authentication failed";
            }
        }
Esempio n. 4
0
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            User user = null;

            if (e.IsAuthenticated)
            {
                //UserInfo = https://www.googleapis,com/oaurh2/v2/userinfo
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <User>(userJson);
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                await store.SaveAsync(account = e.Account, Constants.AppName);
                await DisplayAlert("Email address", user.Email, "OK");
            }
        }
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            if (sender is OAuth2Authenticator authenticator)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            //User user = null;
            if (e.IsAuthenticated)
            {
                // If the user is authenticated, request their basic user data from Google
                // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
                var request  = new OAuth2Request("GET", new Uri(AppConstants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    // Deserialize the data and store it in the account store
                    // The users email address will be used to identify data in SimpleDB
                    string userJson = await response.GetResponseTextAsync();

                    //user = JsonConvert.DeserializeObject<User>(userJson);
                }

                if (account != null)
                {
                    accountStore.Delete(account, AppConstants.AppName);
                }

                await accountStore.SaveAsync(account = e.Account, AppConstants.AppName);

                //await DisplayAlert("Email address", user.Email, "OK");
            }
        }
Esempio n. 6
0
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            User user = null;

            if (e.IsAuthenticated)
            {
                // If the user is authenticated, request their basic user data from Google
                // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    // Deserialize the data and store it in the account store
                    // The users email address will be used to identify data in SimpleDB
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <User>(userJson);
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                await store.SaveAsync(account = e.Account, Constants.AppName);

                //UserDialogs.Instance.Alert("", "Email address: " + user.Email + "\n fullname:" + user.Name + "\n gender:" + user.Gender, "OK");
                MyToast t = new MyToast();
                UserDialogs.Instance.Toast(t.ShowMyToast(Color.Green, "Successful google login"));
                User.Username = user.Email;
                User.Password = user.Email;
            }
            else
            {
                MyToast t = new MyToast();
                UserDialogs.Instance.Toast(t.ShowMyToast(Color.PaleVioletRed, "Unsuccessful google login"));
            }
        }
Esempio n. 7
0
 public void DeleteAccount()
 {
     if (account != null)
     {
         accountStore.Delete(account, CREDENTIALS_NAME);
         account = null;
     }
 }
Esempio n. 8
0
        private async Task <int> ReadFromGmail(Account acc, ICreateListVM vm)
        {
            User user = null;

            // If the user is authenticated, request their basic user data from Google
            // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
            var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, acc);
            var response = await request.GetResponseAsync();

            if (response != null)
            {
                StoreFactory.CurrentVM.Logs.Add("Gmail user info received");

                // Deserialize the data and store it in the account store
                // The users email address will be used to identify data in SimpleDB
                string userJson = await response.GetResponseTextAsync();

                user = JsonConvert.DeserializeObject <User>(userJson);
            }

            if (account != null)
            {
                store.Delete(account, Constants.AppName);
            }

            DateTime date      = DateTime.Now.Subtract(new TimeSpan(vm.Days * 24, 0, 0));
            var      request2  = new OAuth2Request("GET", new Uri(string.Format(Constants.MessageList, "\"" + vm.Subject + "\"", vm.From, date.ToString("yyyy/MM/dd"))), null, acc);
            var      response2 = await request2.GetResponseAsync();

            if (response2 != null)
            {
                StoreFactory.CurrentVM.Logs.Add("Gmail message list received");
                // Deserialize the data and store it in the account store
                // The users email address will be used to identify data in SimpleDB
                string userJson = await response2.GetResponseTextAsync();

                vm.Percentage = 0;
                vm.Messages.Clear();
                foreach (string id in StoreFactory.HalProxy.ReadMailIds(userJson))
                {
                    StoreFactory.CurrentVM.Logs.Add("Gmail message id = " + id);
                    var email = await ReadEmail(id, acc, vm);

                    vm.Messages.Add(email);
                    StoreFactory.HalProxy.RunOnUiThread(
                        new Action(() => { vm.Percentage++; }));
                }
                vm.RaiseChanges();
            }


            await store.SaveAsync(acc, Constants.AppName);

            vm.IsRunning = false;
            StoreFactory.CurrentVM.Logs.Add("Gmail message count = " + vm.Messages.Count);

            return(vm.Messages.Count);
        }
Esempio n. 9
0
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            User user = null;

            if (e.IsAuthenticated)
            {
                // If the user is authenticated, request their basic user data from Google
                // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    // Deserialize the data and store it in the account store
                    // The users email address will be used to identify data in SimpleDB
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <User>(userJson);
                }

                bool resgisted = await new UserViewModel().RegisterUser(user.Id.ToString() + "@ssogoogle.com", e.Account.Properties["access_token"]);

                bool loged = await new UserViewModel().LoginUser(user.Id.ToString() + "@ssogoogle.com", e.Account.Properties["access_token"]);

                if (loged && resgisted)
                {
                    //Loadding.IsRunning = false;
                    await Navigation.PushModalAsync(new NavigationPage(new FastVehicleView()));
                }
                else
                {
                    //Loadding.IsRunning = false;
                    await DisplayAlert("Advertencia", "Tus datos no son correctos", "OK");

                    password.Text = "";
                }

                if (resgisted)
                {
                    resgisted = await new UserViewModel().LoginUser(user.Id.ToString() + "@ssogoogle.com", e.Account.Properties["access_token"]);
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                await store.SaveAsync(account = e.Account, Constants.AppName);
            }
        }
Esempio n. 10
0
        public void DeleteCredentials()
        {
            var account = _accountStore.FindAccountsForService(_AppName).FirstOrDefault();

            if (account != null)
            {
                _accountStore.Delete(account, _AppName);
            }
        }
Esempio n. 11
0
        public async void DeleteCredentials(string userName)
        {
            var account = await GetAccount(userName);

            if (account != null)
            {
                store.Delete(account, App.AppName);
            }
        }
Esempio n. 12
0
        public static void DeleteAccount()
        {
            AccountStore accountStore = AccountStore.Create();
            Account      account      = accountStore.FindAccountsForService(_servideId).SingleOrDefault();

            if (account != null)
            {
                accountStore.Delete(account, _servideId);
            }
        }
Esempio n. 13
0
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }
            if (e.IsAuthenticated)
            {
                User user     = null;
                var  request  = new OAuth2Request("GET", new Uri(Constants.GoogleUserInfoUrl), null, e.Account);
                var  response = await request.GetResponseAsync();

                if (response != null)
                {
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <User>(userJson);
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }
                user.Id = user.Id.Substring(0, 10);

                var loginRequest = new LoginGet();
                loginRequest.Email    = user.Email.ToString();
                loginRequest.GoogleId = Convert.ToInt32(user.Id);

                var result = await service.Logar(loginRequest);

                if (result != null)
                {
                    var pessoa = result.pessoa;
                    Security.Security.TokenValue = result.token.Value;

                    var pagina = new View.Menu(result.pessoa, result.token)
                    {
                        BindingContext = result.pessoa
                    };

                    await Navigation.PushAsync(pagina);
                    await DisplayAlert("Olá", "Seja Bem-Vindo ao FaceIT", "Ok");
                }
                else
                {
                    var cadastro = new View.PessoaFisicaCadastroGoogle(user);
                    await Navigation.PushAsync(cadastro);
                    await DisplayAlert("Aviso", "Antes de acessar, você precisa preencher alguns dados.", "Ok");
                }
            }
        }
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            try
            {
                var authenticator = sender as OAuth2Authenticator;
                if (authenticator != null)
                {
                    authenticator.Completed -= OnAuthCompleted;
                    authenticator.Error     -= OnAuthError;
                }

                User user = null;
                if (e.IsAuthenticated)
                {
                    // DismissViewController(true, null);


                    // If the user is authenticated, request their basic user data from Google
                    var request  = new OAuth2Request("GET", new Uri(MobileConstants.UserInfoUrl), null, e.Account);
                    var response = await request.GetResponseAsync();

                    if (response != null)
                    {
                        // Deserialize the data and store it in the account store
                        // The users email address will be used to identify data in SimpleDB
                        string userJson = await response.GetResponseTextAsync();

                        user = JsonConvert.DeserializeObject <User>(userJson);
                        if (user != null)
                        {
                            await Navigation.PushAsync(new Page1(user?.Email));
                        }
                    }

                    if (account != null)
                    {
                        store.Delete(account, MobileConstants.AppName);
                    }

                    await store.SaveAsync(account = e.Account, MobileConstants.AppName);

                    // await DisplayAlert("Email address", user.Email, "OK");

                    var token = new GoogleOAuthToken
                    {
                        TokenType   = e.Account.Properties["token_type"],
                        AccessToken = e.Account.Properties["access_token"]
                    };
                    // authenticator.IsLoadableRedirectUri()
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 15
0
        protected override void ClearCredentials()
        {
            AccountStore          acStore  = AccountStore.Create(context);
            IEnumerable <Account> accounts = acStore.FindAccountsForService(SERVICE_ID);

            foreach (Account account in accounts)
            {
                acStore.Delete(account, SERVICE_ID);
            }
            base.ClearCredentials();
        }
Esempio n. 16
0
        private void RemoveTokenFromSecureStore()
        {
            var accounts = _accountStore.FindAccountsForService(AppUrlConsts.AppServiceId);

            if (accounts != null)
            {
                foreach (var acct in accounts)
                {
                    _accountStore.Delete(acct, AppUrlConsts.AppServiceId);
                }
            }
        }
Esempio n. 17
0
        public void RemoveTokenFromSecureStore()
        {
            var accounts = AccountStore.FindAccountsForService(Locations.AppName);

            if (accounts != null)
            {
                foreach (var acct in accounts)
                {
                    AccountStore.Delete(acct, Locations.AppName);
                }
            }
        }
        public void RemoveTokenFromSecureStore()
        {
            var accounts = AccountStore.FindAccountsForService(ServiceIdentifier);

            if (accounts != null)
            {
                foreach (var acct in accounts)
                {
                    AccountStore.Delete(acct, ServiceIdentifier);
                }
            }
        }
        public void RemoveTokenFromSecureStore()
        {
            var accounts = AccountStore.FindAccountsForService("tasklist");

            if (accounts != null)
            {
                foreach (var acct in accounts)
                {
                    AccountStore.Delete(acct, "tasklist");
                }
            }
        }
Esempio n. 20
0
        public void ClearSecureStore()
        {
            var accounts = _accountStore.FindAccountsForService(_serviceId);

            if (accounts != null)
            {
                foreach (var acct in accounts)
                {
                    _accountStore.Delete(acct, _serviceId);
                }
            }
        }
Esempio n. 21
0
        public void ClearCachedCredentials()
        {
            AccountStore          accountStore = AccountStore.Create();
            IEnumerable <Account> accounts     = accountStore.FindAccountsForService("Google");
            Account account = accounts.FirstOrDefault();

            if (account == null)
            {
                return;
            }

            accountStore.Delete(account, "Google");
        }
Esempio n. 22
0
        void LogOutFace()
        {
            AccountStore store    = AccountStore.Create();
            var          accounts = store.FindAccountsForService("MasTicket").ToList <Account>();

            if (accounts.Count() > 0)
            {
                foreach (Account a in accounts)
                {
                    store.Delete(a, "MasTicket");
                }
            }
            accounts.Clear();
        }
Esempio n. 23
0
 public bool Delete()
 {
     try
     {
         _account.Properties.Clear();
         _accountStore.Delete(_account, _serviceIdstring);
         return(true);
     }
     catch (AccountStoreException exception)
     {
         Console.WriteLine(exception.StackTrace);
         return(false);
     }
 }
Esempio n. 24
0
        public void RemoveTokenFromSecureStore()
        {
            if (storeAccount == null)
            {
                storeAccount = AccountStore.Create();
            }
            var azure     = storeAccount.FindAccountsForService("azure").FirstOrDefault();
            var facebook  = storeAccount.FindAccountsForService("facebook").FirstOrDefault();
            var localUser = storeAccount.FindAccountsForService("localUser").FirstOrDefault();

            if (azure != null)
            {
                storeAccount?.Delete(azure, nameof(azure));
            }
            if (facebook != null)
            {
                storeAccount?.Delete(facebook, nameof(facebook));
            }
            if (localUser != null)
            {
                storeAccount?.Delete(localUser, nameof(localUser));
            }
        }
Esempio n. 25
0
        public static async void OnAuthCompleted(Object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            UserObj user = null;

            if (e.IsAuthenticated)
            {
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <UserObj>(userJson);
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                await store.SaveAsync(account = e.Account, Constants.AppName);

                Application.Current.Properties.Remove("Id");
                Application.Current.Properties.Remove("FirstName");
                Application.Current.Properties.Remove("LastName");
                Application.Current.Properties.Remove("DisplayName");
                Application.Current.Properties.Remove("EmailAddress");
                Application.Current.Properties.Remove("ProfilePicture");

                Application.Current.Properties.Add("Id", user.Id);
                Application.Current.Properties.Add("FirstName", user.FirstName);
                Application.Current.Properties.Add("LastName", user.LastName);
                Application.Current.Properties.Add("DisplayName", user.Name);
                Application.Current.Properties.Add("EmailAddress", user.Email);
                Application.Current.Properties.Add("ProfilePicture", user.Picture);

                Application.Current.MainPage.Navigation.PopAsync();
                Application.Current.MainPage.Navigation.PushAsync(new TabbedPage1(), true);
            }
        }
Esempio n. 26
0
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            User user = null;

            if (e.IsAuthenticated)
            {
                //UserInfo = https://www.googleapis,com/oaurh2/v2/userinfo
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();



                if (response != null)
                {
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <User>(userJson);
                }
                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                await store.SaveAsync(account = e.Account, Constants.AppName);
                await DisplayAlert("Name", User.Name, "OK");
                await DisplayAlert("Email Address", User.Email, "OK");


                try
                {
                    UsersDb.AddUser(user);
                }
                catch (SqlException ex)
                { }
                App.CurrentUser = user;
            }

            Application.Current.MainPage = new HomePage();
            await Shell.Current.GoToAsync("//main");
        }
Esempio n. 27
0
        private async Task SaveAccessToken(string normalizedUsername, string serviceId, AccessToken accessToken,
                                           CancellationToken cancellationToken)
        {
            await Task.Factory.StartNew(
                () =>
            {
                var account = _accountStore.FindAccountsForService(serviceId).FirstOrDefault(a => string.Equals(a.Username, normalizedUsername,
                                                                                                                StringComparison.CurrentCultureIgnoreCase));

                if (account != null)
                {
                    _accountStore.Delete(account, serviceId);
                }
                _accountStore.Save(new Account(normalizedUsername, accessToken.ToDictionary()), serviceId);
            },
                cancellationToken).ConfigureAwait(false);
        }
Esempio n. 28
0
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            User user = null;

            if (e.IsAuthenticated)
            {
                // If the user is authenticated, request their basic user data from Google
                // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    // Deserialize the data and store it in the account store
                    // The users email address will be used to identify data in SimpleDB
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <User>(userJson);
                }
                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }
                Application.Current.Properties["User"] = user;
                await store.SaveAsync(account = e.Account, Constants.AppName);

                Application.Current.Properties["Account"]            = (await store.FindAccountsForServiceAsync(Constants.AppName)).FirstOrDefault();
                Application.Current.Properties["Signed"]             = true;
                Xamarin.Forms.Application.Current.Properties["Boff"] = "Hello " + user.Name + "\n" + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Welcome2");
                loader.Tokenise();
            }
            else
            {
                Xamarin.Forms.Application.Current.Properties["Boff"] = "error";
            }
        }
        async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            User user = null;

            if (e.IsAuthenticated)
            {
                // If the user is authenticated, request their basic user data from Google
                // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
                var request  = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    // Deserialize the data and store it in the account store
                    // The users email address will be used to identify data in SimpleDB
                    string userJson = await response.GetResponseTextAsync();

                    user = JsonConvert.DeserializeObject <User>(userJson);
                }

                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }

                try { await store.SaveAsync(account = e.Account, Constants.AppName); }
                catch { await DisplayAlert("Email address", "keychain", "OK"); }

                Xamarin.Forms.Application.Current.Properties["Boff"]   = "Hello " + user.Name + "! \nWelcome to GreenBank";
                Xamarin.Forms.Application.Current.Properties["First"]  = user.GivenName;
                Xamarin.Forms.Application.Current.Properties["Last"]   = user.FamilyName;
                Xamarin.Forms.Application.Current.Properties["Signed"] = true;
                Application.Current.Properties["Account"] = e.Account;
            }
        }
Esempio n. 30
0
        void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnAuthCompleted;
                authenticator.Error     -= OnAuthError;
            }

            if (e.IsAuthenticated)
            {
                getProfileButton.IsEnabled = true;

                if (this.account != null)
                {
                    store.Delete(this.account, ServiceId);
                }

                store.Save(account = e.Account, ServiceId);

                getProfileButton.IsEnabled = true;

                if (account.Properties.ContainsKey("expires_in"))
                {
                    var expires = int.Parse(account.Properties["expires_in"]);
                    statusText.Text = "Token lifetime is: " + expires + "s";
                }
                else
                {
                    statusText.Text = "Authentication succeeded";
                }

                if (account.Properties.ContainsKey("refresh_token"))
                {
                    refreshButton.IsEnabled = true;
                }
            }
            else
            {
                statusText.Text = "Authentication failed";
            }
        }