【问题标题】:Gmail API google.auth.exceptions.RefreshError Invalid scopeGmail API google.auth.exceptions.RefreshError 无效范围
【发布时间】:2020-06-05 07:38:26
【问题描述】:

我正在编写一个命令行工具,它使用 gmail api 从邮箱下载报告。我正在使用 quickstart.py(转换为 python3)进行身份验证。但是,当令牌过期一段时间后无法刷新时,这很有效。我明白了:

文件“/home/ayoub/.local/lib/python3.6/site-packages/google/oauth2/_client.py”,第 248 行,在 refresh_grant response_data = _token_endpoint_request(请求,token_uri,正文) _token_endpoint_request 中的文件“/home/ayoub/.local/lib/python3.6/site-packages/google/oauth2/_client.py”,第 124 行 _handle_error_response(response_body) _handle_error_response 中的文件“/home/ayoub/.local/lib/python3.6/site-packages/google/oauth2/_client.py”,第 60 行 引发异常。RefreshError(error_details, response_body) google.auth.exceptions.RefreshError: ('invalid_scope: 一些请求的范围无效。{invalid=[a, c, e, g, h, i, l, m, ., /, o, p, s, t, :]}', '{\n "error": "invalid_scope",\n "error_description": "一些请求的范围无效。{invalid\u003d[a, c, e, g, h, i, l, m , ., /, o, p, s, t, :]}",\n "error_uri": "http://code.google.com/apis/accounts/docs/OAuth2.html"\n}')

我已确保我没有更改我的范围并创建了一个新的 credentials.json 文件。我也尝试过升级所有使用的库。有没有人遇到过这个或知道解决方案?谢谢!

【问题讨论】:

  • 你好@Ayoub-del!你用了什么范围?你是如何声明它们的?干杯!
  • @ale13 谢谢!我看了一下我在哪里声明了我的范围,它们不在括号内。添加括号解决了我的问题。

标签: oauth-2.0 google-oauth gmail-api


【解决方案1】:

您遇到的错误是由于范围声明不当造成的。声明范围的适当方式是这样的:

var SCOPES = ['SCOPE 1', 'SCOPE 2',...]

【讨论】:

    猜你喜欢
    • 2022-12-16
    • 2015-05-18
    • 2015-03-20
    • 1970-01-01
    • 1970-01-01
    • 2017-01-04
    • 2018-01-02
    • 1970-01-01
    • 2017-03-26
    相关资源
    最近更新 更多