javascript - How to get email address with google access token? - Stack Overflow

I'm not able to get the email id from the ResponseHere the Response:{"id": "000000

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": ".jpg",
  "locale": "en"
}

and this is what I'm using:

=' + 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./-2Sv-4bBMLLA/AAAAAAAAAAI/AAAAAAAAABo/bEG4kI2mG0I/photo.jpg",
  "locale": "en"
}

and this is what I'm using:

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

Share Improve this question edited Mar 27, 2018 at 12:58 mplungjan 178k28 gold badges182 silver badges240 bronze badges asked Mar 27, 2018 at 12:56 MahendraMahendra 3372 gold badges6 silver badges16 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

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

Now i'm able to get the email in respone, below is the code, where i changed the Response in the manifest

"oauth2": {
"client_id": "854569859639-9c0reicivklkv0ltpakv99iajqts5obs.apps.googleusercontent.",
 "scopes": [ "https://www.googleapis./auth/userinfo.email" ]}

i changd the scope "scopes": [ "https://www.googleapis./auth/plus.login" ] to
"scopes": [ "https://www.googleapis./auth/userinfo.email" ]

and below is the response

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744104147a4558650.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信