Google+ api doesn't return profile name with login request

后端 未结 5 1184
挽巷
挽巷 2021-01-16 04:48

The google documentation HERE clearly says that

You should not request userinfo.profile or plus.me in combination with [https://www.googleapis.com/au

5条回答
  •  清酒与你
    2021-01-16 05:26

    Seems like Google is a little vague in its documentation. They say the scope 'plus.login' contains the displayName and email, however, after running several tests with different Google accounts (plain Gmail, Google+, Google Apps) this seems to be false.

    If the user doesn't have a Google+ profile, 'plus.login' will NOT contain displayName. This also seems to happen to Google Apps accounts. So, to cover all possible Google Account status, the safe bet is to request for:

    • https://www.googleapis.com/auth/plus.login
    • https://www.googleapis.com/auth/plus.me
    • https://www.googleapis.com/auth/userinfo.email
    • https://www.googleapis.com/auth/userinfo.profile

    They say the last 2 are deprecated, however, some accounts will not return all basic information if you don't use them. I don't know if this is related to the "age" of the Google account or just a bug on Google's end.

提交回复
热议问题