How do I get user profile using Google Access Token

jq beginner picture jq beginner · May 11, 2013 · Viewed 48.8k times · Source

i'm testing getting user information by google access token

http://www.mawk3y.net/glogin

after clicking sign in button i get redirected to

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=access_token_here

And get some JSON data like this

{
"issued_to": "my client id.apps.googleusercontent.com",
"audience": "my client id.apps.googleusercontent.com",
"user_id": "user id here",
"scope": "https://www.googleapis.com/auth/plus.login",
"expires_in": 3596,
"access_type": "online"
}

now i need to know how to extract user name , address and email any help please ?

thanks in advance

Answer

betmakh picture betmakh · Jul 16, 2015

Try this one:

 var url = 'https://www.googleapis.com/plus/v1/people/me?access_token={access_token}';

  $.ajax({
    type: 'GET',
    url: url,
    async: false,
    success: function(userInfo) {
      //info about user
      console.log(userInfo);
      console.log('test');
    },
    error: function(e) {
      console.log('error');

    }
  });