Enable Google API for “googleapis.com/auth/userinfo”

扶醉桌前 提交于 2019-12-24 15:23:20

问题


I am developing a Google Chrome Extension. I would like to be able to access the user profile info, using the data from these endpoints:

https://www.googleapis.com/auth/userinfo

https://www.googleapis.com/oauth2/v1/userinfo

I don't seem to have access to these resources. From my web searches, it looks like I may need to enable a library API in the Google Developers Console. But I looked there and cannot find an appropriate API to enable. Does anyone know which API I should enable?


回答1:


If you need just user's email-address for auth etc., you have to enable Google's Plus API, not the G**-*****d People API which is mentioned everywhere in the Google Cloud API docs.

Also, you need to mention the scope https://www.googleapis.com/auth/userinfo.email, not the https://www.googleapis.com/auth/userinfo.profile one.

p.s. It's an old question, yet unanswered. Possibly, you've already solved it. I'm posting it for people from the future, or just for my future self.




回答2:


You can retrieve data from these endpoints if you have an access token from the user. First, you have to get an access token by letting the user login using google login API. Then retrieve the data from the following link. https://www.googleapis.com/oauth2/v1/userinfo?access_token=PUT_YOUR_USER'S_ACCESS_TOKEN_HERE



来源:https://stackoverflow.com/questions/48632883/enable-google-api-for-googleapis-com-auth-userinfo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!