[英]Google Authentication using Tornado Web Framework(Python)
我將Tornado Web框架用於其異步回調功能,並嘗試在Tornado中使用OAuth設置Google身份驗證。
當前,身份驗證進入到要求我訪問數據的權限的步驟,然后由於無法與我的應用程序交換訪問令牌而出現“ No Data Received
屏幕。
您可以用一些代碼更新您的問題嗎? 我可以根據錯誤或您更新的代碼來更新我的答案。
如果您想參考一些文檔,可以查看http://tornado.readthedocs.org/en/latest/auth.html
以下是示例代碼,可以為您提供幫助。
class GoogleOAuth2LoginHandler(tornado.web.RequestHandler,
tornado.auth.GoogleOAuth2Mixin):
@tornado.gen.coroutine
def get(self):
if self.get_argument('code', False):
user = yield self.get_authenticated_user(
redirect_uri='http://your.site.com/auth/google',
code=self.get_argument('code'))
# Save the user with e.g. set_secure_cookie
else:
yield self.authorize_redirect(
redirect_uri='http://your.site.com/auth/google',
client_id=self.settings['google_oauth']['key'],
scope=['profile', 'email'],
response_type='code',
extra_params={'approval_prompt': 'auto'})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.