GetAuthSubToken 返回 None

发布于 2024-08-25 10:28:21 字数 1460 浏览 10 评论 0原文

嘿伙计们,我对如何获取身份验证令牌有点迷失。这是我在授权我的应用程序返回时使用的代码:

client = gdata.service.GDataService()
gdata.alt.appengine.run_on_appengine(client)
sessionToken = gdata.auth.extract_auth_sub_token_from_url(self.request.uri)
client.UpgradeToSessionToken(sessionToken)
logging.info(client.GetAuthSubToken())

记录的内容是“无”,所以这似乎是正确的:-( 如果我使用这个:

temp = client.upgrade_to_session_token(sessionToken)
logging.info(dump(temp))

我得到这个:

{'scopes': ['http://www.google .com/calendar/feeds/'], 'auth_header': 'AuthSub token=CNKe7drpFRDzp8uVARjD-s-wAg'}

所以我可以看到我正在获取 AuthSub 令牌,我想我可以解析它并获取令牌,但这似乎不是事情应该进行的方式。

如果我尝试使用 AuthSubTokenInfo 我得到这个:

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 507, in __call__
    handler.get(*groups)
  File "controllers/indexController.py", line 47, in get
    logging.info(client.AuthSubTokenInfo())
  File "/Users/matthusby/Dropbox/appengine/projects/FBCal/gdata/service.py", line 938, in AuthSubTokenInfo
    token = self.token_store.find_token(scopes[0])
TypeError: 'NoneType' object is unsubscriptable

所以看起来我的 token_store 没有正确填写,这是我应该做的事情吗?

我也在使用 gdata 2.0.9

谢谢 马特

Hey guys, I am a little lost on how to get the auth token. Here is the code I am using on the return from authorizing my app:

client = gdata.service.GDataService()
gdata.alt.appengine.run_on_appengine(client)
sessionToken = gdata.auth.extract_auth_sub_token_from_url(self.request.uri)
client.UpgradeToSessionToken(sessionToken)
logging.info(client.GetAuthSubToken())

what gets logged is "None" so that does seem right :-(
if I use this:

temp = client.upgrade_to_session_token(sessionToken)
logging.info(dump(temp))

I get this:

{'scopes': ['http://www.google.com/calendar/feeds/'], 'auth_header': 'AuthSub token=CNKe7drpFRDzp8uVARjD-s-wAg'}

so I can see that I am getting a AuthSub Token and I guess I could just parse that and grab the token but that doesn't seem like the way things should work.

If I try to use AuthSubTokenInfo I get this:

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 507, in __call__
    handler.get(*groups)
  File "controllers/indexController.py", line 47, in get
    logging.info(client.AuthSubTokenInfo())
  File "/Users/matthusby/Dropbox/appengine/projects/FBCal/gdata/service.py", line 938, in AuthSubTokenInfo
    token = self.token_store.find_token(scopes[0])
TypeError: 'NoneType' object is unsubscriptable

so it looks like my token_store is not getting filled in correctly, is that something I should be doing?

Also I am using gdata 2.0.9

Thanks
Matt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

獨角戲 2024-09-01 10:28:21

回答我自己的问题:

当您获得令牌时,只需调用:

client.token_store.add_token(sessionToken)

App Engine 就会为您将其存储在新的实体类型中。然后,当调用日历服务时,不要设置 authsubtoken,因为它也会为您处理这个问题。

To answer my own question:

When you get the Token just call:

client.token_store.add_token(sessionToken)

and App Engine will store it in a new entity type for you. Then when making calls to the calendar service just dont set the authsubtoken as it will take care of that for you also.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文