Find Google+ avatar for given email address without OAuth

做~自己de王妃 提交于 2020-01-09 19:06:54

问题


In my app I want to show the Google+ profile picture for a user. The only function, I found, in the API to get the profile picture needs a userId. However, I only have their email adress and not their Google+ userID.
Moreover the person, whose image I want to get, should not be forced to log in and authorize my app, as this person is mostly not identical to the user of the app.

So I think I need to get their userId by email. I read through the Google+ API documentation but can't find a way to do this, but I can't believe that this is not possible.

So my question is:
How can I get the Google+ userID with only an email address?
Is there maybe an other Google API to get a profile picture?


回答1:


There is an API provided by https://www.avatarapi.com/ which returns the user's name and profile pic from an email address based on Google's public info.

It can be called via SOAP or HTTP at this API endpoint: https://www.avatarapi.com/avatar.asmx

One of the benefits of this API is that it does not require the user to be authenticated with Google via OAUTH, so this could be exactly what you are looking for.




回答2:


You can't do this using just their email address, however, if they paste their Google+ url, you could parse the id from the URL string and then get their profile image (and cover image!) using the public data API. The url: https://plus.google.com/me will bring you to their profile.




回答3:


I highly doubt this is possible. Any kind of querying against the Google Plus API requires OAUTH. What's more, I'm not aware of way to query for a user ID by email address in the first place.

This thread would seem to confirm that this is currently not possible.




回答4:


You can use the people.search API to search by email address and without requesting the user to authenticate. However, that will only search the public profile fields, which email is not a public field by default.

The only API methods that require OAuth are those that access private data. For public data, you can use the more simple API key method.

To reliably achieve what you are describing, you'll want to use Oauth and the plus.me scope to get the information that you want. This does require authorizing your app however.



来源:https://stackoverflow.com/questions/14243200/find-google-avatar-for-given-email-address-without-oauth

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