I am currently trying to develop a GAE application.
I followed this tutorial in order to get access to gdocs using OAuth.
http://code.google.com/appengine/articles/python/retrieving_gdata_feeds.html
What I can’t understand is how to reuse this token afterwards.
If I directly try to access feeds on a second connection, I got bounced due to a lack of authorization (401).
I think I have to authenticate each time using the access_token in my Gdocs object, but can’t find the right way to do it.
Any ideas?
My code is the same as in the tutorial, plus:
# Create an instance of the DocsService to make API calls
gdocs = gdata.docs.client.DocsClient(source = SETTINGS['APP_NAME'])
class MainPage(webapp.RequestHandler):
@login_required
def get(self):
my_user = users.get_current_user()
# I think I have to authenticate, but don't know how here
token_key = 'access_token_%s' % my_user.user_id()
access_token = gdata.gauth.ae_load(token_key)
gdocs.auth_token = gdocs.get_access_token(access_token)
feed = gdocs.GetResources()
for entry in feed.entry:
template = '<div>%s</div>'
self.response.out.write(template % entry.title.text)
Which is launched by default.
I know I have access to the token key using ae_load(token_key), as I can print it.
Should I use gdocs to authenticate, or a more general client, as I is shown here :
http://ikaisays.com/2011/05/26/setting-up-an-oauth-provider-on-google-app-engine/
I checked and my token is listed in my private google account.
Thanks by advance !
I finally answered my own question by searching in google apis.
Here is how I use it :
Another version could be this :
as states google ‘s doc.