0

editied original question:

Im trying to make a google appengine app which uses the g+ avatar and human name...

...

So it seems that i need the google-api-python-client library in my app.

...

to enable access to the profile scope so i can look up 'me' and grab the users name and avatar and chuck them in a couple of properties in my user objects (with a button to reload the values again or something).

So has anyone does this? Or has a working example (or even a pointer to which of the ways to authorise my app for scope=[profile])?


Discoveries:

I dont need the google-api-python-client library for this. The simple approach was to do the g+ access in pure js on the client and then lookup and push the results to my appengine app. It isnt as secure as doing via the backend, but it is only for displayname and icon (which can be set manually anyway).

I did need to make some other tweaks to make it work though...

following this workflow: https://developers.google.com/+/web/signin/javascript-flow

Important things to note:

  • step1 should also state that you MUST fill out "APIs & auth" -> "Consent screen" field "PRODUCT NAME" and "EMAIL ADDRESS" or you get weird errors

    You (might) have to do this before you generate the credential (or delete and recreate it)

    (credit to answer: Error: invalid_client no application name)

  • set meta google-signin-scope to "profile" (or maybe "email")

  • remove the meta header for google-signin-requestvisibleactions (otherwise i got a frame sameorigin error)

  • obviously the button line from step4 needs to go after the body tag in your document

  • skip step2, the code from step2 is also included in step4

  • also on the workflow page, the 'working example' button on that page does not work (dont try it)

Once i did that I could put the following in the successful callback code and do a lookup:

gapi.client.load('plus','v1', function(){
  var request = gapi.client.plus.people.get({ 'userId': 'me' });
  request.execute(function(resp) {
   console.log('Retrieved profile for:' + resp.displayName);
   console.log(resp);
   console.log(resp.result);
   console.log(resp.result.displayName);
   console.log(resp.result.image);
 });
});
Community
  • 1
  • 1

1 Answers1

1

you can see here full example on how to use client library

https://code.google.com/p/google-api-python-client/source/browse/samples/plus/plus.py

i see a snippet of the code stating

try:
    person = service.people().get(userId='me').execute()

    print 'Got your ID: %s' % person['displayName']

https://developers.google.com/+/api/latest/people#resource

so basically person['image']['url'] will be your path to user's avatar.

full folder: https://code.google.com/p/google-api-python-client/source/browse/samples/plus/

vertazzar
  • 1,053
  • 7
  • 10
  • thanks for the reply.. i ended up not doing it on python, but rather in js. Along the way i found a few things that might have been breaking my attempts to do it in python (and might be breaking it for other people too). – Cameron Blackwood Aug 29 '14 at 06:02