views:

177

answers:

1

I am having trouble upgrading my session token in google app engine if my user is not logged into my application using the google accounts user api, if the user is currently logged in then it functions perfectly.

If not then i am getting this error:

Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 511, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/5th-anniversary/1.341853888797531127/main.py", line 78, in get
    u.upgradeToken(self)
  File "/base/data/home/apps/5th-anniversary/1.341853888797531127/upload.py", line 47, in upgradeToken
    client.UpgradeToSessionToken()
  File "/base/data/home/apps/5th-anniversary/1.341853888797531127/gdata/service.py", line 903, in UpgradeToSessionToken
    raise NonAuthSubToken
NonAuthSubToken 

What are my best options here? i do not want the user to have to log into the google accounts api and then the youtube site to upload a video..

here is my method for updating the token:

def upgradeToken(data,self):
    get = self.request.GET
    authsub_token = get['token']

    gdata.alt.appengine.run_on_appengine(client)

    client.SetAuthSubToken(authsub_token)
    client.UpgradeToSessionToken()

client is simply client = gdata.youtube.service.YouTubeService()

pretty sure i'm missing something on the authentication side but i can't seem to see what, thanks!

A: 

I solved this by using:

client.UpgradeToSessionToken(gdata.auth.extract_auth_sub_token_from_url(self.request.url))

but this raised another issue when building the upload form with

GetFormUploadToken

i receive:

Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 513, in __call__
    handler.post(*groups)
  File "/base/data/home/apps/5th-anniversary/1.341859541699944556/upload.py", line 106, in post
    form = u.getUploadForm(self,title,description,keywords)
  File "/base/data/home/apps/5th-anniversary/1.341859541699944556/upload.py", line 65, in getUploadForm
    response = client.GetFormUploadToken(video_entry,'http://gdata.youtube.com/action/GetUploadToken')
  File "/base/data/home/apps/5th-anniversary/1.341859541699944556/gdata/youtube/service.py", line 716, in GetFormUploadToken
    raise YouTubeError(e.args[0])
YouTubeError: {'status': 401L, 'body': '<HTML>\n<HEAD>\n<TITLE>User authentication required.</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>User authentication required.</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n', 'reason': ''}
Alex