I have used google app engine with django application. I have been using the user api from google to login in my website and also getting the current user email address from that, but i have to get profile picture which is uploded on the google plus account.
I am getting their profile picture using,
<img src="https://plus.google.com/s2/photos/profile/<user_id>?sz=100" width="100" height="100">
in google api.
User class also provides user_id
but I cannot get their profile picture using that user_id
.
<user_id> and user_id of user class of Google API
is different.
How to get the profile picture in my application?
The way to do it is to use the google+ api here: https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=me&_h=2&
This is the request to pull the image for the currently authenticated user.
GET https://www.googleapis.com/plus/v1/people/me?key={YOUR_API_KEY}
You'll get a json response like this and it's really easy to parse that and pull out the image->url value to display.
{
"kind": "plus#person",
"etag": "\"XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXx\"",
"gender": "male",
"emails": [
{
"value": "[email protected]",
"type": "account"
}
],
"objectType": "person",
"id": "XxXxXxXxXxXxXxXxXxXxXxXx",
"displayName": "John Brahy",
"name": {
"familyName": "Brahy",
"givenName": "John"
},
"url": "https://plus.google.com/XxXxXxXxXxXxXxXxXxXxXxXx",
"image": {
"url": "https://lh3.googleusercontent.com/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/photo.jpg?sz=50"
},
"isPlusUser": true,
"language": "en",
"circledByCount": 2,
"verified": false,
"cover": {
"layout": "banner",
"coverPhoto": {
"url": "https://lh5.googleusercontent.com/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/Green%2BGrass.jpg",
"height": 240,
"width": 420
},
"coverInfo": {
"topImageOffset": 0,
"leftImageOffset": 0
}
},
"domain": "XxXxXxXx-x.com"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With