0

I'm working on a small app that will allow the user to login to the App, allow the app OAuth access to a service, then interact with the service using the app via email.

I've successfully enabled Oauth using gdata and gdata.gauth and can store/recover the Oauth token and user_id easily when the user is logged in.

However, when receiving an email, I try to get the user_id by creating a users.User(email="senders.email@gmail.com") but end up getting a None value for the user_id.

ie:

when logged in:

current_user = users.get_current_user()
current_user.user_id() #this is a valid id when the user is logged in

when receiving an email (using the mail handler):

current_user = users.User(email="sender.email@gmail.com")
current_user.user_id() #this returns None

Any hints on how to make this work?

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
ngingd
  • 43
  • 5

1 Answers1

1

Reading http://code.google.com/appengine/docs/python/users/userclass.html#User

Under the method call user_id, it is noted that if you create the User object yourself, the user_id field will return None.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
  • Thanks - I can't believe I missed that even though I've read that page about 50x. I'm building a workaround that uses the datastore to associate an email address with user id, and rebuild the authtoken from that. Many thanks for the quick response. For those that are in the same predicament, I used http://stackoverflow.com/questions/5569074/retrieving-token-and-secret-from-gdata-gauth-oauthhmactoken-python-object to guide the 'rebuild' – ngingd Oct 28 '11 at 19:15