Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Data API authentication
    text
    copied!<p>I am trying to get my Django app (NOT using Google app engine) retrieve data from Google Contacts using Google Contacts Data API. Going through <a href="http://code.google.com/apis/accounts/docs/AuthSub.html" rel="nofollow noreferrer">authentication documentation</a> as well as <a href="http://code.google.com/apis/contacts/docs/1.0/developers_guide_python.html" rel="nofollow noreferrer">Data API Python client docs</a></p> <p>First step (AuthSubRequest) which is getting the single-use token works fine. The next step(AuthSubSessionToken), which is upgrade single-use token to a session token. The python API call UpgradeToSessionToken() simply didn't work for me it gave me NonAuthSubToken exception:</p> <pre><code>gd_client = gdata.contacts.service.ContactsService() gd_client.auth_token = authsub_token gd_client.UpgradeToSessionToken() </code></pre> <p>As an alternative I want to get it working by "manually" constructing the HTTP request:</p> <pre><code>url = 'https://www.google.com/accounts/AuthSubSessionToken' headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'AuthSub token=' + authsub_token, 'User-Agent': 'Python/2.6.1', 'Host': 'https://www.google.com', 'Accept': 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2', 'Connection': 'keep-alive', } req = urllib2.Request(url, None, headers) response = urllib2.urlopen(req) </code></pre> <p>this gives me a different error: </p> <p>HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop. The last 30x error message was: Moved Temporarily</p> <p>What am I doing wrong here? I'd appreciate help/advice/suggestions with either of the methods I am trying to use: Python API call (UpgradeToSessionToken) or manually constructing HTTP request with urllib2.</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