Python 未登录Google帐户用户API,无法升级YouTube会话令牌
如果我的用户没有使用google accounts用户api登录到我的应用程序,我在升级google app engine中的会话令牌时遇到问题。如果用户当前已登录,则其功能完美 如果不是,则我将得到以下错误:Python 未登录Google帐户用户API,无法升级YouTube会话令牌,python,google-app-engine,youtube-api,google-account,Python,Google App Engine,Youtube Api,Google Account,如果我的用户没有使用google accounts用户api登录到我的应用程序,我在升级google app engine中的会话令牌时遇到问题。如果用户当前已登录,则其功能完美 如果不是,则我将得到以下错误: Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 511, in __c
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
我最好的选择是什么?我不希望用户必须先登录谷歌账户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
我很确定我在身份验证方面遗漏了一些东西,但我似乎看不到什么,谢谢 我用以下方法解决了这个问题:
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': ''}
试试这个:
new_token = client.UpgradeToOAuthAccessToken(
gdata.auth.extract_auth_sub_token_from_url(self.request.url)
client.SetOAuthToken(new_token)
client.GetFormUploadToken(my_video_entry)