コード例 #1
0
        public async void OnAuthenticationCompleted(GoogleOAuthToken token, Account account)
        {
            //Retrieve the user's email address
            var googleService = new GoogleService();
            var email         = await googleService.GetEmailAsync(token.TokenType, token.AccessToken);

            //Add email address to account
            account.Properties.Add("Email", email);

            //Retrieve IdToken
            //var idToken = await googleService.GetOpenIdAsync(token.TokenType, token.AccessToken, account);

            //Display email on the UI
            //var googleButton = FindViewById<Button>(Resource.Id.googleLoginButton);
            //googleButton.Text = $"Connected with {email}";

            //Save logged in user
            CredentialsService credentialsService = new CredentialsService();

            credentialsService.SaveCredentials(account);

            var intent = new Intent(this, typeof(MainActivity));

            StartActivity(intent);
            Finish();
        }
コード例 #2
0
 private void OnAuthenticationCompleted(object sender, AuthenticatorCompletedEventArgs e)
 {
     if (e.IsAuthenticated)
     {
         var token = new GoogleOAuthToken
         {
             TokenType   = e.Account.Properties["token_type"],
             AccessToken = e.Account.Properties["access_token"]
         };
         _authenticationDelegate.OnAuthenticationCompleted(token, e.Account);
     }
     else
     {
         _authenticationDelegate.OnAuthenticationCancelled();
     }
 }