Google将OAuth/OpenID与Tornado联合:为什么它忽略了我的作用域?

Google将OAuth/OpenID与Tornado联合:为什么它忽略了我的作用域?,oauth,tornado,google-data-api,google-openid,google-data,Oauth,Tornado,Google Data Api,Google Openid,Google Data,我正在尝试使用Tornado的联合登录库来验证用户身份,并访问他们的日历、联系人和邮件。然而,当我收到mydomain.dyndns.info请求从您的Google帐户消息中获取一些信息时,列出的唯一要点是电子邮件地址。随后,当我在批准请求后检查返回的用户对象时,该用户对象没有“access\u token”属性 代码如下: def get(self): scope_list = ['https://mail.google.com/','http://www.google.com/m8/

我正在尝试使用Tornado的联合登录库来验证用户身份,并访问他们的日历、联系人和邮件。然而,当我收到mydomain.dyndns.info请求从您的Google帐户消息中获取一些信息时,列出的唯一要点是电子邮件地址。随后,当我在批准请求后检查返回的用户对象时,该用户对象没有“access\u 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资源不需要注册应用程序,但这可能不再是事实了


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

找到了答案。您必须设置应用程序属性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)
您可以通过以下方式获得: