Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since the Task Queue task will be spawned by your application, none of the headers from your original request will be sent through. In particular, the <code>Cookies</code> header identifying your user via the <code>SACSID</code> cookie for your application (provided by the App Engine Users API).</p> <p><strong>UPDATE: (This was added after the original post.)</strong> As a result of no cookies, the <code>SACSID</code> cookie identifying the user won't be there, hence the <code>decorator.oauth_required</code> designation will force a redirect (which is HTTP <code>302</code>) <strong>EVERY</strong> time the cron job runs.</p> <p>Instead of trying to get the current user from the decorator, you are better off passing along the App Engine User ID to your task. First get the current user (within your decorated method):</p> <pre><code>from google.appengine.api import users # Guaranteed not to be None by the decorator current_user = users.get_current_user() </code></pre> <p>and then pass along the App Engine User ID in the task</p> <pre><code>import urllib query_string = urllib.urlencode({'user_id': current_user.user_id()}) taskqueue.add(url='/updateworker?' + query_string) </code></pre> <p>Then within your task, you can retrieve grab that <code>user_id</code></p> <pre><code># This is the 'user_id' you appended in the query string user_id = self.request.get('user_id') </code></pre> <p>and use it to get that user's credentials <a href="https://code.google.com/p/google-api-python-client/source/browse/oauth2client/appengine.py?r=ae2ff74e239820776304fadcba8f9b476efd913b#692" rel="noreferrer">as is done in the decorator</a>:</p> <pre><code>from oauth2client.appengine import CredentialsModel from oauth2client.appengine import StorageByKeyName # This assumes you are using the defaults for OAuth2Decorator, # which your above code is credentials = StorageByKeyName( CredentialsModel, user_id, 'credentials').get() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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