Gmail API 返回 403 错误代码和“Delegation denied for <user email>" [英] Gmail API returns 403 error code and "Delegation denied for <user email>"

查看:27
本文介绍了Gmail API 返回 403 错误代码和“Delegation denied for <user email>"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检索邮件时,Gmail API 针对一个域失败:

Gmail API fails for one domain when retrieving messages with this error:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 OK
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "Delegation denied for <user email>",
    "reason" : "forbidden"
  } ],
  "message" : "Delegation denied for <user email>"
}

我使用 OAuth 2.0 和 Google Apps 域范围授权来访问用户数据.域已授予应用程序数据访问权限.

I am using OAuth 2.0 and Google Apps Domain-Wide delegation of authority to access the user data. The domain has granted data access rights to the application.

推荐答案

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

Seems like best thing to do is to just always have userId="me" in your requests. That tells the API to just use the authenticated user's mailbox--no need to rely on email addresses.

这篇关于Gmail API 返回 403 错误代码和“Delegation denied for &lt;user email&gt;"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆