【问题标题】:How to solve Gspread oauth refresher token error?如何解决 Gspread oauth 刷新令牌错误?
【发布时间】: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

标签: python oauth gspread


【解决方案1】:

通过在开发者控制台中删除我的 Google API 项目来解决。然后从头开始创建一个新的项目和服务帐户。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-05
    • 2019-05-02
    • 1970-01-01
    • 2017-11-20
    • 2013-06-08
    • 1970-01-01
    • 2016-03-31
    • 2012-12-21
    相关资源
    最近更新 更多