My favorites | Sign in
Google
                
Search
for
Updated Aug 21, 2008 by api.jscudder
AuthSubWithTextDB  
gdata.spreadsheets.text_db was designed to use ClientLogin, but it can also use AuthSub

Sample

This short sample will create a new Google Spreadsheet after you have authenticated using AuthSub.

import gdata.spreadsheet.text_db

client = gdata.spreadsheet.text_db.DatabaseClient()
auth_url = client._GetDocsClient().GenerateAuthSubURL(next=YOUR_WEB_APPS_URL,
    scope='http://spreadsheets.google.com/feeds/ http://docs.google.com/feeds/documents/')

The page listed as YOUR_WEB_APPS_URL will need to examine it's URL and extract the value from the 'token' URL parameter.

client._GetDocsClient().SetAuthSubToken(token)
client._GetDocsClient().UpgradeToSessionToken()
client._GetSpreadsheetsClient().SetAuthSubToken(client._GetDocsClient().GetAuthSubToken())

db = client.CreateDatabase('google_spreadsheets_db auth sub test')

Comment by jmvidal, May 15, 2009

If I call client.GetDocsClient?().UpgradeToSessionToken?() I get a NonAuthSubToken? excetion.

If, instead, I call client.GetDocsClient?().UpgradeToSessionToken?(token) then I get a "DownloadError?: ApplicationError?: 2 nonnumeric port"

Thus, I can't get it to work. Could you post a full example? like step3.py from http://code.google.com/appengine/articles/gdata.html Thanks!

Comment by jmvidal, May 15, 2009

I think you need to add

    gdata.alt.appengine.run_on_appengine(client)
    gdata.alt.appengine.run_on_appengine(client._GetDocsClient())
    gdata.alt.appengine.run_on_appengine(client._GetSpreadsheetsClient())

Sign in to add a comment