0

我正在尝试使用 Tornado 的库进行联合登录来验证用户身份并访问他们的日历、联系人和邮件。但是,当我收到“mydomain.dyndns.info 正在向您的 Google 帐户询问一些信息”消息时,列出的唯一要点是“电子邮件地址”。随后,当我在批准请求后检查返回的用户对象时,用户对象没有“access_token”属性。

这是代码:

def get(self):
    scope_list = ['https://mail.google.com/','http://www.google.com/m8/feeds/','http://www.google.com/calendar/feeds/']
    ...
    self.authorize_redirect(scope_list, callback_uri=self._switch_command('auth_callback'), ax_attrs=["name","email"])
def _on_auth(self, user):
    print 'in on auth'
    if user:
        self.set_the_user(user['email'])
        session.set_data('usertoken_' + user['email'], user['access_token'])
    self.redirect('/')

这吐出的uri是:

https://www.google.com/accounts/o8/ud
?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.return_to=http%3A%2F%2Fmydomain.dyndns.info%3A333%2Fauth%2Fauth_callback%3Fperms%3Dgmail%26perms%3Dcontacts%26perms%3Dcalendar
&openid.realm=http%3A%2F%2Fmydomain.dyndns.info%3A333%2F
&openid.mode=checkid_setup
&openid.ns.oauth=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Foauth%2F1.0
&openid.oauth.consumer=mydomain.dyndns.info
&openid.oauth.scope=https%3A%2F%2Fmail.google.com%2F+http%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F+http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F
&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0
&openid.ax.type.fullname=http%3A%2F%2Faxschema.org%2FnamePerson
&openid.ax.type.lastname=http%3A%2F%2Faxschema.org%2FnamePerson%2Flast
&openid.ax.type.firstname=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffirst
&openid.ax.mode=fetch_request
&openid.ax.type.email=http%3A%2F%2Faxschema.org%2Fcontact%2Femail
&openid.ax.required=firstname%2Cfullname%2Clastname%2Cemail

想法: 1.也许这与我在 dyndns 转发器后面的本地机器上运行的事实有关?2. Tornado 的文档说“无需注册应用程序即可使用 Google 进行身份验证或代表用户访问 Google 资源”——但也许这不再适用了?

如果有人有想法,我真的很感激——这让我有点发疯!

4

1 回答 1

0

弄清楚了。您必须设置应用程序属性 google_consumer_key 和 google_consumer_secret。

application = tornado.web.Application(urlhandlers, cookie_secret=cookie_secret, google_consumer_key=google_consumer_key, google_consumer_secret=google_consumer_secret)

你可以去这里得到它们: https: //www.google.com/accounts/ManageDomains

于 2011-03-21T16:48:09.867 回答