Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 龙卷风谷歌oauth错误_Python_Oauth_Tornado - Fatal编程技术网

Python 龙卷风谷歌oauth错误

Python 龙卷风谷歌oauth错误,python,oauth,tornado,Python,Oauth,Tornado,我遇到了tornado.oauth的下一个问题:当用户使用Google登录时,Google向我的重定向uri发送代码,然后我尝试使用函数get\u authenticated\u user获取有关用户的信息 class GoogleOAuth2CodeHandler(tornado.web.RequestHandler, tornado.auth.GoogleOAuth2Mixin): @tornado.gen.coroutine

我遇到了tornado.oauth的下一个问题:当用户使用Google登录时,Google向我的重定向uri发送代码,然后我尝试使用函数
get\u authenticated\u 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!")
但它失败了,出现了下一个错误:

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

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"
    ))
消费者密钥
消费者密钥
正确
authorize\u redirect
工作正常,我确实从OAuth1 google mixin获得了正确的google代码
google\u consumer\u密钥
google\u consumer\u secret
。对于oauth2,您需要一个
google_oauth
设置,它应该是一个包含“key”和“secret”字段的dict:

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

注意:您可能不需要双重关闭支架。