Google API:刷新令牌时出现ConnectionResetError

时间:2018-07-24 08:54:12

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

以下代码因错误而失败 "ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host"行中的http = credentials.refresh(http)

from googleapiclient.discovery import build
import httplib2
import pickle

#credentials is a GoogleCredentials object generated during the auth flow
credentials = pickle.load(open("credentials.pickle", "rb"))
http = httplib2.Http()
http = credentials.refresh(http)
service = build('analytics', 'v4', http=http)

使用http = credentials.authorize(http)而不是.refresh运行代码,它可以很好地工作。在此阶段,我完全不知如何解决此问题,朝正确方向的任何提示将不胜感激。

0 个答案:

没有答案