简体   繁体   English

龙卷风谷歌oauth错误

[英]Tornado google oauth error

I have the next problem with tornado.oauth : when user logs in with Google,Google sends me code to my redirect uri and then I try to get some information about user with the function get_authenticated_user 我有tornado.oauth的下一个问题:当用户使用Google登录时,Google将代码发送给我的重定向uri,然后尝试使用get_authenticated_user函数获取有关用户的一些信息

class GoogleOAuth2CodeHandler(tornado.web.RequestHandler,
                           tornado.auth.GoogleOAuth2Mixin):
    @tornado.gen.coroutine
    def get(self):
        user =yield self.get_authenticated_user(
            redirect_uri='http://localhost:8890/userdata',
            code=self.get_argument("code")
        )
        self.write("hello world!")

but it fails with the next error: 但失败并出现下一个错误:

ERROR:tornado.application:Uncaught exception GET
KeyError: 'google_oauth'

Settings: 设定:

settings = dict(
        cookie_secret="32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
        login_url="/auth/login",
        redirect_uri="http://localhost:8890/auth",
        google_consumer_key="",
        google_consumer_secret="",
        google_permissions="https://mail.google.com/ https://www.google.com/m8/feeds",
        google_permissions2="https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
    ))

consumer_key and consumer_secret are correct authorize_redirect works correctly and I really get correct google code consumer_keyconsumer_secret是正确的authorize_redirect可以正常工作,而且我确实获得了正确的Google代码

google_consumer_key and google_consumer_secret are from the OAuth1 Google mixin. google_consumer_keygoogle_consumer_secret来自OAuth1 Google mixin。 For oauth2, you need a google_oauth setting, which should be a dict containing 'key' and 'secret' fields: 对于oauth2,您需要一个google_oauth设置,该设置应为包含'key'和'secret'字段的字典:

  google_oauth={"key": CLIENT_ID, "secret": CLIENT_SECRET},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM