Python 龙卷风谷歌oauth错误
我遇到了tornado.oauth的下一个问题:当用户使用Google登录时,Google向我的重定向uri发送代码,然后我尝试使用函数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
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},
注意:您可能不需要双重关闭支架。