问题
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