I'm writing an email-based application using the gmail-api, and i need to retrieve user public images for email address originating from google. I've seen other applications do that, but i can't seem a way to reliably get this data.
some more information:
- i'm using oauth2 to sign the user in - and i have no problem requesting any type of permissions there.
- i've tried retrieving the image using the google+ api - but it requires a userID for that - and i don't know how to get the userId for the email address (gmail-api doesn't give it, afaik).
- i've tried using the contacts API - but it only gives images for the user's contacts, while the email clients can display images from other users as well.
Thanks!
Edit:
I know i can receive the required images from google plus, if i have the other user's userid. however, i can't find a way to get the userid based on an email address.
May be too late in answering the question but the best way i found was to first use http://picasaweb.google.com/data/entry/api/user/?alt=json
from the JSON Response you will get author section which has uri: $t: https:picasaweb.google.com/0000000000000
now the numbers at the end is the USER ID which can be used to Retrieve user profile using this API
https:www.googleapis.com/plus/v1/people/userId
Ex: https:www.googleapis.com/plus/v1/people/0000000000000
I banged my head against this for days, since none of the answers seemed to work anymore. What did work and looks more robust against future changes was (it uses jQuery):
You need a Google OAuth2 client id - see https://developers.google.com/identity/protocols/OAuth2UserAgent for the details. It does not seem to work just with an API Key - from the responses I was getting they have set the quota for unauthenticated access to the API (I.e. just using the Key and not the ClientID) to zero.
The Client ID is available from the cloud console as documented on the link - I think you need to create a project to create the credentials but if you are not using it they will not charge you so that is not a problem.The user does need to be logged in - if not this code will log then in. But if you are not using a Google login for your page anyway - why would you want their thumbnail? Because the image URL is available from the basic user profile . - the API request does not seem to need any particular scope and there is none in the API call in the code.
You will need to identify the url for page that you are calling from as part of your client credentials in the Google console - otherwise the request will be denied. There is a quota - I think it is 20,000 a day - of free API calls after which they will charge you for using the API. That is as much as I can gather.