コード例 #1
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);
     }
     else
     {
         _authenticationDelegate.OnAuthenticationCanceled();
     }
 }
コード例 #2
0
        private async 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"]
                };

                string UserInfoUrl = "https://www.googleapis.com/oauth2/v2/userinfo";
                var    request     = new OAuth2Request("GET", new Uri(UserInfoUrl), null, e.Account);
                var    response    = await request.GetResponseAsync();

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

                    Debug.WriteLine(userJson);

                    var account = JsonConvert.DeserializeObject <GoogleAccount>(userJson);
                    Debug.WriteLine("id: " + account.id);
                    Debug.WriteLine("name: " + account.name);
                    Debug.WriteLine("link: " + account.link);
                    Debug.WriteLine("picture: " + account.picture);
                    Debug.WriteLine("gender: " + account.gender);

                    AccountViewModel.UserID         = account.id;
                    AccountViewModel.Username       = account.name;
                    AccountViewModel.UserProfileImg = account.picture;
                }

                _authenticationDelegate.OnAuthenticationCompleted(token);
            }
            else
            {
                _authenticationDelegate.OnAuthenticationCanceled();
            }
        }
コード例 #3
0
        public 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();

                superToken = token.AccessToken;

                //System.Diagnostics.Debug.WriteLine(token);
                //System.Diagnostics.Debug.WriteLine(superToken);
                //System.Diagnostics.Debug.WriteLine(token.TokenType);
                //System.Diagnostics.Debug.WriteLine(token.AccessToken);
            }
            else
            {
                _authenticationDelegate.OnAuthenticationCanceled();
            }
        }