I’m trying to access the Google Analytics API from a Google App Engine app. I 
got this working a long time ago, before Analytics was one of the APIs you 
could use server-to-server.

So I have code that works with an administrator user in the middle of the 
transaction. I used the decorator from oauth2client.appengine import 
oauth2decorator_from_clientsecrets

What I’d like to do is get this working so my google app engine app (written in 
Python) can just talk to google analytics without a person in the loop. I can’t 
find an example of that.

Since all the google services seem to work the same way, I probably don’t need 
an example of connecting to analytics. Rather, just an example of how to 
connect to any google service without a user in the middle would be great.

The following code doesn’t work, but hopefully will give you an idea of what 
I’m trying to do. It is failing because there’s no callback set up.

class StorageDuck():
  def put(self, content):
    console.log("Pretending to put: "+content)

class GetGAHandler(webapp2.RequestHandler):
  def get(self):
    from apiclient.discovery import build
    from oauth2client import client
    from oauth2client import file
    from oauth2client import tools
    http = httplib2.Http(memcache)
    service = build("analytics", "v3", http=http)
    flow = client.flow_from_clientsecrets(
      CLIENT_SECRETS,
      scope='https://www.googleapis.com/auth/analytics.readonly',
      message="")
    credentials = tools.run(flow, StorageDuck())
    chttp = credentials.authorize(http=httplib2.Http())

Any pointers?

-Joshua

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/AD42F353-F9AC-4433-B6F2-4EF9863448C3%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to