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 に答える