繁体   English   中英

使用适用于Python的Google API客户端库连接到Google Analytics(分析)时发生SSLHandshakeError

[英]SSLHandshakeError when connecting to Google Analytics using Google APIs Client Library for Python

我正在尝试使用服务帐户连接到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

似乎是由于系统时钟未设置为当前时间而出现问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM