V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Tornado Documentation
http://www.v2ex.com/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
ant_sz
V2EX  ›  Tornado

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

  •  
  •   ant_sz · 2012-04-07 00:40:58 +08:00 · 6368 次点击
    这是一个创建于 4396 天前的主题,其中的信息可能已经有所发展或是发生改变。
    仅仅是按照官方文档中,写了一个谷歌认证的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'

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

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

    噗,这个问题只会在本地测试时出现么?
    Livid
        4
    Livid  
    MOD
       2012-04-07 00:59:16 +08:00
    @ant_sz 服务器上用的肯定是 IDC 的 DNS,所以实际部署之后是不会有问题的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   913 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 21:01 · PVG 05:01 · LAX 14:01 · JFK 17:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.