【发布时间】:2016-05-23 11:09:55
【问题描述】:
我在使用 tornado 框架的 Google+ OAuth 中遇到问题。我使用 AngularJS 作为前端,使用 python tornado 作为 nginx 服务器的后端。我从 AngularJS 向 Google+ API 发送 HTTP 请求,我的 tornado API 被重定向到 Google 登录。成功登录后,它会重定向回我的应用程序。在重定向时,我认为它会自动刷新,即来自 Google 的两个重定向调用。
看到有两个来自 tornado OAuth2 的 HTTP 重定向调用
这是我的代码:
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'}
错误:
Google 身份验证错误:HTTPResponse(_body=None,buffer=<_io.bytesio object at>,code=400,effective_url='https://accounts.google.com/o/oauth2/token',error=HTTPError('HTTP 400: Bad Request',), headers={'X-Consumed-Content-Encoding': 'gzip', 'Alternate-Protocol': '443:quic,p=1', 'X-Xss-Protection': '1; mode=block', ' X-的Content-Type-选项: 'nosniff', '传送编码': '分块', '的Set-Cookie':“NID = 76 = iaY_jJFPzvLg3_h3eqUFMt4fecbELKk9_bGJju-mwsHBNlxeDqSrtmpyazsrJ3mDgtDnTnzsw5_fjIfV8GcUAegoNgxGi5ynpcfg0vEWULSeVXKio_ANxEoK9C-F5oRs;域= .google.com;路径= / ;Expires=Sat,2016 年 8 月 13 日 10:17:46 GMT;HttpOnly','Expires':'Fri,2016 年 2 月 12 日 10:17:46 GMT','服务器':'GSE','连接': 'close', 'Cache-Control': 'private, max-age=0', 'Date': 'Fri, 12 Feb 2016 10:17:46 GMT', 'P3p': 'CP="This is not a P3P 策略!有关详细信息,请参阅 https://support.google.com/accounts/answer/151657?hl=en。"', 'Alt-Svc': 'quic=":443"; ma=604800; v="30,29,28,27,26,25"', ' Content-Type': 'application/json; charset=utf-8', 'X-Frame-Options': 'SAMEORIGIN'},reason='Bad Request',request=,reque st_time=0.4158029556274414,time_info={})
【问题讨论】:
-
请帮帮我..
标签: python angularjs nginx tornado google-oauth