views:

58

answers:

1

Hey guys, I am a little lost on how to get the auth token. Here is the code I am using on the return from authorizing my app:

client = gdata.service.GDataService()
gdata.alt.appengine.run_on_appengine(client)
sessionToken = gdata.auth.extract_auth_sub_token_from_url(self.request.uri)
client.UpgradeToSessionToken(sessionToken)
logging.info(client.GetAuthSubToken())

what gets logged is "None" so that does seem right :-( if I use this:

temp = client.upgrade_to_session_token(sessionToken)
logging.info(dump(temp))

I get this:

{'scopes': ['http://www.google.com/calendar/feeds/'], 'auth_header': 'AuthSub token=CNKe7drpFRDzp8uVARjD-s-wAg'}

so I can see that I am getting a AuthSub Token and I guess I could just parse that and grab the token but that doesn't seem like the way things should work.

If I try to use AuthSubTokenInfo I get this:

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 507, in __call__
    handler.get(*groups)
  File "controllers/indexController.py", line 47, in get
    logging.info(client.AuthSubTokenInfo())
  File "/Users/matthusby/Dropbox/appengine/projects/FBCal/gdata/service.py", line 938, in AuthSubTokenInfo
    token = self.token_store.find_token(scopes[0])
TypeError: 'NoneType' object is unsubscriptable

so it looks like my token_store is not getting filled in correctly, is that something I should be doing?

Also I am using gdata 2.0.9

Thanks Matt

A: 

To answer my own question:

When you get the Token just call:

client.token_store.add_token(sessionToken)

and App Engine will store it in a new entity type for you. Then when making calls to the calendar service just dont set the authsubtoken as it will take care of that for you also.

Matt