【问题标题】:Delegation denied for user@domain.comuser@domain.com 的委派被拒绝
【发布时间】:2019-11-19 01:09:39
【问题描述】:

我正在使用 goodle gmail 发送 API 来发送邮件。

POST https://www.googleapis.com/gmail/v1/users/me/messages/send?key=[My_API_KEY]

Authorization: Bearer [ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json

{
  "raw": "SGkgVGVhbSwKVGVzdGluZyBFbWFpbCBBdXRoZW50aWNhdGlvbgoKCgoK"
}

当我执行此操作时,我收到如下错误:

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "forbidden",
                "message": "Delegation denied for mymailaddress@example.com"
            }
        ],
        "code": 403,
        "message": "Delegation denied for mymailaddress@example.com"
    }
}

谁能帮我解决这个问题。 提前谢谢你。

【问题讨论】:

标签: gmail-api


【解决方案1】:

试试这些-

1. 最好的办法是在您的请求中始终包含 'userId="me" '。这告诉 API 只使用经过身份验证的用户的邮箱——无需依赖电子邮件地址。

2. JSON 中存在的访问令牌和其他参数与新的电子邮件 ID/帐户无关。因此,为了使其运行,您只需删除“.credentails”文件夹并再次运行程序。现在,程序打开浏览器并要求您授予权限。
在python中删除包含文件的文件夹

import shutil
shutil.rmtree("path of the folder to be deleted")

你可以在程序末尾添加这个

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 2014-11-25
    • 1970-01-01
    • 2021-07-11
    • 2017-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多