3
votes

I guess Gmail API doesn't provide any way to get users profile image.

I can use Google+ API to get the url but I should have user's google+ username.

I only have user's email id and his/her account access token(gmail).

The answer to this question points to a url hosted by picasaweb.google.com which is discontinued now and also does not return any result for emailid of users with Gsuite account.

1

1 Answers

0
votes

If you have authenticated the user. You should be able to use people.get

GET https://www.googleapis.com/plus/v1/people/me

response

"image": {
  "url": "https://lh5.googleusercontent.com/-a1CWlFnA5xE/AAAAAAAAAAI/AAAAAAAAl1I/UcwPajZOuN4/photo.jpg?sz=50",
  "isDefault": false
 },

This will require that you have profile scope requested or one of these.

https://www.googleapis.com/auth/plus.login or https://www.googleapis.com/auth/plus.me

It will also require that the user created a google+ account. This is the only way to get the users profile picture unfortunately.

Option two is the people api which is linked to google contacts which may include the users profile picture if they added it. People.get

GET https://people.googleapis.com/v1/people/me?personFields=photos

Also returns

"url": "https://lh5.googleusercontent.com/-a1CWlFnA5xE/AAAAAAAAAAI/AAAAAAAAl1I/UcwPajZOuN4/s100/photo.jpg"