Tornado 第三方认证的问题,Google Openid

2012-04-07 00:40:58 +08:00
 ant_sz
仅仅是按照官方文档中,写了一个谷歌认证的Handler如下:

class GoogleHandler(tornado.web.RequestHandler, tornado.auth.GoogleMixin):
@tornado.web.asynchronous
def get(self):
if self.get_argument("openid.mode", None):
self.get_authenticated_user(self.async_callback(self._on_auth))
return
self.authenticate_redirect()

def _on_auth(self, user):
if not user:
raise tornado.web.HTTPError(500, "Google auth failed")
print user

但是在实际使用中却出现问题了
登陆到google后成功返回,但是_on_auth函数却没能正确的识别出User

抛出错误如下:

CertificateError: hostname u'www.google.com' doesn't match either of '*.gstatic.com', 'gstatic.com', '*.metric.gstatic.com'
WARNING:root:Invalid OpenID response: hostname u'www.google.com' doesn't match either of '*.gstatic.com', 'gstatic.com', '*.metric.gstatic.com'

为啥会出现这个错误啊。。。求助各位大神。。。
6382 次点击
所在节点    Tornado
4 条回复
Livid
2012-04-07 00:51:17 +08:00
是在本地测试的时候出现这个错误的对吧?

因为 V2EX DNS 会将 www.google.com 指向一个离我们更近更稳定的 gstatic.com 节点……
ant_sz
2012-04-07 00:54:43 +08:00
原来是dns的原因啊。。。我试试换dns
ant_sz
2012-04-07 00:58:20 +08:00
@Livid 果然如此。。。感谢Livid~~~~~~~

噗,这个问题只会在本地测试时出现么?
Livid
2012-04-07 00:59:16 +08:00
@ant_sz 服务器上用的肯定是 IDC 的 DNS,所以实际部署之后是不会有问题的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/31566

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX