本文介绍了Gmail API返回403错误代码和“拒绝<用户电子邮件"的授权.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下错误检索邮件时,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 Domain-Wide授权来访问用户数据.该域已授予该应用程序数据访问权限.

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错误代码和“拒绝&lt;用户电子邮件"的授权.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 03:12