[英]Tornado google oauth error
我有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!")
但失败并出现下一个错误:
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"
))
consumer_key
和consumer_secret
是正确的authorize_redirect
可以正常工作,而且我确实获得了正确的Google代码
google_consumer_key
和google_consumer_secret
来自OAuth1 Google mixin。 对于oauth2,您需要一个google_oauth
设置,该设置应为包含'key'和'secret'字段的字典:
google_oauth={"key": CLIENT_ID, "secret": CLIENT_SECRET},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.