Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>tl;dr;</p> <p>try this inside appengine code:</p> <pre><code>from google.appengine.api import oauth oauth.get_current_user(SCOPE) </code></pre> <hr> <p>I've been to the same path for the past week, wandering among vague google documents.</p> <p>My final understanding is that AppEngine never officially made it to the OAuth2 land. You see these 'OAuth1 being deprecated' messages all over google API documents, but it's actually quiet in appengine documents. It talks about OAuth, but does not talk about which version. </p> <p>This is the landscape of what I think the current status is (as of 2013-12-07):</p> <ul> <li><a href="https://developers.google.com/appengine/docs/python/oauth/" rel="nofollow noreferrer" title="Google AppEngine OAuth">[1] Authorizing into appengine with OAuth</a>: the <code>*.appspot.com/_ah/</code> approach. Doesn't say which version. Likely 1.0 only.</li> <li><a href="https://developers.google.com/api-client-library/python/guide/aaa_oauth" rel="nofollow noreferrer" title="Google APIs client python library">[2] Google API Authorization</a>: all the OAuth2 fuss, but it's about requesting other Google APIs, not much about appengine.</li> <li><a href="https://developers.google.com/accounts/docs/OAuth2Login" rel="nofollow noreferrer" title="Google Accounts Authentication, Using OAuth 2.0 for Login">[3] Google accounts authentication with OAuth 2.0</a>: logging in with general google account. Unfortunately appengine is not included in the scope.</li> </ul> <p>There is another document that talks about <a href="https://developers.google.com/api-client-library/python/guide/google_app_engine" rel="nofollow noreferrer">OAuth 2.0 on appengine</a>, but it's about calling Google APIs from appengine server, not logging into it.</p> <p>I tried accessing appengine server with the OAuth2 approach in [<a href="https://developers.google.com/accounts/docs/OAuth2Login" rel="nofollow noreferrer" title="Google Accounts Authentication, Using OAuth 2.0 for Login">3</a>], but <code>oauth.get_current_user()</code> method raised an exception. Also tried various scopes, hoping one would fit for appengine, only to fail.</p> <p>However,</p> <p>What I found out <a href="https://stackoverflow.com/questions/7810607/google-app-engine-oauth2-provider/10855271#10855271">from another SO answer</a>, was an <strong>undocumented</strong> use of the method:</p> <pre><code>oauth.get_current_user('https://www.googleapis.com/auth/userinfo.email') </code></pre> <p>passing the scope as an argument. And this worked, provided the consumer had passed the access token with the scope.</p> <p>And it turned out it was in the <a href="https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/oauth/oauth_api.py?spec=svn404&amp;r=400#85" rel="nofollow noreferrer">appengine code</a> after all. It just wasn't <a href="https://developers.google.com/appengine/docs/python/oauth/functions#get_current_user" rel="nofollow noreferrer">documented</a>.</p> <p>Improvements or corrections to any misunderstandings are welcome.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload