mrmo123
mrmo123

Reputation: 725

OAuth for Google App Engine Python

I've been carefully reading documentation on how to implement OAuth for GAE Python here: https://cloud.google.com/appengine/docs/python/oauth/#Python_OAuth_and_App_Engine

The steps below make sense. But I have no idea how to make all this work. All I want to do is be able to access https://www.googleapis.com/oauth2/v1/userinfo so that a user can store his/her email in the app's ndb.

Step 1: import oauth

from google.appengine.api import oauth

Step 2: get current user

user = oauth.get_current_user()

Step 3: get request token https://your_app_id.appspot.com/_ah/OAuthGetRequestToken

Step 4: authorize token https://your_app_id.appspot.com/_ah/OAuthAuthorizeToken

Step 5: get access token https://your_app_id.appspot.com/_ah/OAuthGetAccessToken

Step 6: get information from google 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=TOKENWOULDGOHERE

I can't find any good examples that I can use to help me solve this problem. From what I've found, it seems I always get either an import error or an authentication error. For example ImportError: No module named oauth2client.client

I would be eternally grateful if anyone could write me a sample or point me in the right direction to simply grab a user's email address from OAuth2 using GAE Python. Thank you so much!

Upvotes: 3

Views: 2580

Answers (1)

Ryan
Ryan

Reputation: 2542

This video really helped me get OAuth working. Using decorators simplifies the whole process.

Upvotes: 3

Related Questions