V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Tornado Documentation
https://study.congcong.us/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
ant_sz
V2EX  ›  Tornado

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

  •  
  •   ant_sz · Apr 7, 2012 · 7121 views
    This topic created in 5140 days ago, the information mentioned may be changed or developed.
    仅仅是按照官方文档中,写了一个谷歌认证的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 replies    1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
    PRO
       Apr 7, 2012
    是在本地测试的时候出现这个错误的对吧?

    因为 V2EX DNS 会将 www.google.com 指向一个离我们更近更稳定的 gstatic.com 节点……
    ant_sz
        2
    ant_sz  
    OP
       Apr 7, 2012
    原来是dns的原因啊。。。我试试换dns
    ant_sz
        3
    ant_sz  
    OP
       Apr 7, 2012
    @Livid 果然如此。。。感谢Livid~~~~~~~

    噗,这个问题只会在本地测试时出现么?
    Livid
        4
    Livid  
    MOD
    PRO
       Apr 7, 2012
    @ant_sz 服务器上用的肯定是 IDC 的 DNS,所以实际部署之后是不会有问题的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2283 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 01:33 · PVG 09:33 · LAX 18:33 · JFK 21:33
    ♥ Do have faith in what you're doing.