Search code examples
javascriptgoogle-chrome-extensionoauth-2.0

How to get email address with google access token?


I'm not able to get the email id from the Response Here the Response:

{
  "id": "00000000000000",
  "name": "Fred Example",
  "given_name": "Fred",
  "family_name": "Example",
  "picture": "https://lh5.googleusercontent.com/-2Sv-4bBMLLA/AAAAAAAAAAI/AAAAAAAAABo/bEG4kI2mG0I/photo.jpg",
  "locale": "en"
}

and this is what I'm using:

https://www.googleapis.com/oauth2/v1/userinfo?access_token=' + token


Solution

  • You may need a different scope. According to documentation, the scope https://www.googleapis.com/auth/userinfo.profile allows you to see basic profile info. In order to see the e-mail, you need this scope: https://www.googleapis.com/auth/userinfo.email.