Google OAuth API to get user's email address?

前端 未结 11 855
栀梦
栀梦 2020-11-29 01:38

I am playing with Google\'s OAuth 2.0 Playground using my own personal Google account, but I cannot seem to recover my Gmail address using the playground.

The scope

11条回答
  •  没有蜡笔的小新
    2020-11-29 01:48

    I came here looking why my server did not get email in response to /oauth2/v2/userinfo api call. It was only once that I saw this & it has been working well in past.

    The answer gave good lead. While fixing this, there were several other resources that helped. Still I am not sure whether expecting always email in the response is ok. so - put error handling in code in case emails are not returned.

    1. Google api documentation about migrating to google+ signin.
    2. https://www.googleapis.com/auth/userinfo.email scope
    3. People resource documentation
    4. Add google+ api to the project using google developer console. The complimentary (quota) of calls is quite high (20m for google+ signin api per day).
    5. Add error handling & logging in server code in case api returns no emails. In my case, I was looking only type='account' email.

提交回复
热议问题