【发布时间】:2016-11-20 11:26:38
【问题描述】:
我有一个 gspread Python 脚本,它已经完美运行了 6 个月。现在突然我在尝试授权我的服务帐户凭据时收到一个错误。
这是错误:
raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: internal_failure
这是我的验证码:
scope = ['http://spreadsheets.google.com/feeds',
'https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name("assets/My Project-0101001.json", scope)
google_client = gspread.authorize(credentials)
我尝试过创建新的服务帐户,甚至使用完全不同的谷歌帐户来生成新的刷新令牌,但对我来说没有任何效果。这很烦人,因为脚本几个月都没有问题,现在突然决定失败。有人可以帮忙吗?
【问题讨论】:
-
我之前没见过
internal_failure。您是否尝试使用credentials.refresh()刷新凭据? -
我已经尝试过
credentials.refresh(),但我只是收到一个错误,因为我没有传入 http 对象。我不确定该怎么做。 -
抱歉,请尝试传递
refresh()期望的 http 对象。即credentials.refresh(httplib2.Http()),在此之前不要忘记import httplib2。 -
谢谢。我刚刚尝试过
credentials.refresh(httplib2.Http()),当我尝试强制刷新 access_token 时,我仍然得到相同的 Traceback。我完全不知道为什么会发生这种情况。 -
我只能建议在新的 Python 环境(或 virtualenv)中从头开始。确保您安装了最新的 oauth2client。我能找到的与 Google API 相关的唯一
internal_failure信息在这里 groups.google.com/forum/#!topic/adwords-api/f13W-C4ffL4