How to get user email from google plus oauth

Marian Petrov picture Marian Petrov · Jul 23, 2012 · Viewed 68k times · Source

Link: https://sites.google.com/site/oauthgoog/Home/emaildisplayscope

From the link above I add the email scope

https://www.googleapis.com/auth/plus.me
https://www.googleapis.com/auth/userinfo.email

But I dont understand the following

Once you have a valid OAuth token, you can use it to make API calls to the Email Display API endpoint: https://www.googleapis.com/userinfo/email If the token is not valid, a 401 error will be returned. If the token is valid, then the user's Email address will be returned. The API will also return a boolean value to indicate whether Google has verified that the user owns that Email address. However most installed applications will ignore that value.

How to make a call to the Email Display API endpoint? Using https://www.googleapis.com/userinfo/email

Answer

Joseph Rajeev Motha picture Joseph Rajeev Motha · Jul 23, 2012

Set your scopes to:

And use the endpoint:

https://www.googleapis.com/oauth2/v1/userinfo?alt=json

Usage:

get https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=youraccess_token

You will get JSON:

{ "id": "xx", 
  "name": "xx", 
  "given_name": "xx", 
  "family_name": "xx", 
  "link": "xx", 
  "picture": "xx", 
  "gender": "xx", 
  "locale": "xx" 
}