I’m using exactly the code in the examples from here: http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html#Auth
Still no dice.
Here is the exact code I’ve got (this is all running on a web server):
#!/usr/bin/python
import gdata.photos.service
import gdata.media
import gdata.geo
print "content-type:text/html\n"
def GetAuthSubUrl():
next = 'http://my_domain.com/foo/connect_picasa.cgi'
scope = 'http://picasaweb.google.com/data/'
secure = False
session = True
gd_client = gdata.photos.service.PhotosService()
return gd_client.GenerateAuthSubURL(next, scope, secure, session);
authSubUrl = GetAuthSubUrl();
print '<a href="%s">Login to your Google account</a>' % authSubUrl
And then at my_domain/foo/connect_picasa.cgi I have:
#!/usr/bin/python
import gdata.photos.service
import gdata.media
import gdata.geo
import cgi
parameters = cgi.FieldStorage()
authsub_token = parameters['token']
print "content-type:text/html\n"
#debugging
print authsub_token
gd_client = gdata.photos.service.PhotosService()
gd_client.auth_token = authsub_token
gd_client.UpgradeToSessionToken()
#more debugging
print "BLINKENLICHTEN"
It’s bailing out at gd_client.UpgradeToSessionToken() with: raise NonAuthSubToken
Maybe I’m missing something obvious here? Doing parameters['token'] and parameters['token'].value [which seems more obvious to me] result in the same thing. Setting the authsub_token to “tacos”, also results in the same error, leading me to believe that my authsub_token in simply invalid.
I’m answering my own question so that others can benefit from it:
The google documentation is out of date. Found the answer here: http://www.mail-archive.com/google-calendar-help-dataapi@googlegroups.com/msg09180.html
This is what the code should look like:
It does need the actual value. So either give it a .value, or use parameters.getvalue(“token”)
This is the important part. Use gd_client.SetAUthSubToken, not gd_client.authsubtoken =
Hope this helps anybody else out. This was a real headbanger.