[英]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.