【问题标题】:SSLHandshakeError when connecting to Google Analytics using Google APIs Client Library for Python使用适用于 Python 的 Google API 客户端库连接到 Google Analytics 时出现 SSLHandshakeError
【发布时间】:2013-08-23 09:49:29
【问题描述】:

我正在尝试使用服务帐户连接到 Google Analytics,但出现以下错误:

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('XXXX@developer.gserviceaccount.com', 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

【问题讨论】:

    标签: python google-analytics-api google-api-python-client


    【解决方案1】:

    问题似乎是因为系统时钟没有设置为当前时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-15
      • 1970-01-01
      • 1970-01-01
      • 2019-12-11
      • 1970-01-01
      • 2016-06-07
      • 2014-02-02
      相关资源
      最近更新 更多