2013-08-23 68 views
0

我試圖使用服務帳戶連接到谷歌Analytics(分析),但我得到了以下錯誤:SSLHandshakeError時,谷歌Analytics(分析)使用谷歌API客戶端庫的Python

SSLHandshakeError at ... 
[Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 

我已經安裝了PyOpenSSL和PyCrypto並更新。

這是我用來連接代碼:

from oauth2client.client import SignedJwtAssertionCredentials 
from apiclient.discovery import build 
import httplib2 

def initialize_service(): 
    f = open('path_to_key_file.p12', 'rb') 

    key = f.read() 
    f.close()  
    credentials = SignedJwtAssertionCredentials('[email protected]', key, scope='https://www.googleapis.com/auth/analytics.readonly') 
    http = httplib2.Http() 
    http = credentials.authorize(http) 
    print 'This is printed' 
    service = build('analytics', 'v3', http=http) 
    print 'This is not printed' 

    return service 

回答

0

似乎出現問題,因爲系統時鐘未設置爲當前時間。