2011-12-16 81 views
0

我試圖使用Google plus API來瀏覽OAuth2流程。httplib2.CertificateHostnameMismatch in Google plus API

我得到了驗證者,我將要交換訪問令牌,然後發生錯誤。

httplib2.CertificateHostnameMismatch: 

Server presented certificate that does not match host accounts.google.com: 

服務器提供的證書不匹配主機www.googleapis.com

提供的證書(通用名)爲* .g.doubleclick.net

爲何不同??

我的代碼是這樣的:

from oauth2client.client import flow_from_clientsecrets 

CLIENT_SECRETS = 'client_secrets.json' 

MISSING_CLIENT_SECRETS_MESSAGE = "" 

FLOW = flow_from_clientsecrets(CLIENT_SECRETS, 
    scope='https://www.googleapis.com/auth/plus.me', 
    message=MISSING_CLIENT_SECRETS_MESSAGE) 

    FLOW.step1_get_authorize_url() 
    # the url is outputted and 
    # my browser forward to it to get the verifier 

    FLOW.step2_exchange(verifier) 
    # I paste the verifier and execute this line, then error occurred. 

任何提示?

PS:urllib2版本是0.7.2

+0

如果我是正確的,你還需要通過request_token你有第一步得到access_token – 2011-12-17 05:02:39

回答

1

對於任何人誰已經過具有CertificateHostnameMismatch錯誤就這個問題迷迷糊糊的,我建議你檢查哪個Python版本您正在使用(python --version)。

我在使用Python 2.7.2,結果證明有一些已知的問題/迴歸SSL證書處理。我升級到2.7分支的最新版本,我的CertificateHostnameMismatch錯誤消失了。