2010-05-10 74 views
1

如果我的用戶未使用Google帳戶用戶api登錄到我的應用程序,則在升級我的會話令牌時遇到問題。如果用戶當前登錄,那麼它的功能完美。無法登錄Google帳戶用戶API無法升級YouTube會話令牌

如果沒有,那麼我得到這個錯誤:

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 

什麼是我的最佳選擇嗎?我不希望用戶必須登錄到Google帳戶API,然後才能上傳YouTube視頻。

這裏是我的更新標記方法:

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 = gdata.youtube.service.YouTubeService()

很肯定我的思念在認證方面的東西,但我似乎無法看到了什麼,謝謝!

回答

0

我解決了這個利用:

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

但這與

GetFormUploadToken 

構建上載表單時提出了另外一個問題,我得到:

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': ''} 
0

試試這個:

new_token = client.UpgradeToOAuthAccessToken(
    gdata.auth.extract_auth_sub_token_from_url(self.request.url) 
client.SetOAuthToken(new_token) 
client.GetFormUploadToken(my_video_entry)