Gmail 标签请求失败,并显示 http 403(禁止访问)



我有一个使用 OAuth 2 访问 Gmail 的应用程序。 这对大多数用户来说工作正常。 但是,对于某些用户,我的应用程序在尝试读取Gmail标签时失败,出现http错误403(禁止)。 请记住,在此 API 调用之前,我已经成功访问了用户配置文件。 下面是失败的调用:

GET /gmail/v1/users/user.name@domain.com/labels?access_token=ya29.fwI_zL1rF3xOIQcHNzpBhmjVlJhRpofkh4a9mVvwhYRo6H09qX5RNKv76zKT7e6-sEZr

我在获取访问令牌时请求以下范围,并且用户已登录Google并接受了访问请求(当我们查看他的安全仪表板时,我可以看到这一点):

https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/userinfo.profile
https://www.google.com/m8/feeds
https://www.googleapis.com/auth/tasks
https://www.googleapis.com/auth/gmail.labels
https://mail.google.com/

请注意,我刚刚添加了gmail.labels范围,试图解决此问题。同样,此代码对大多数用户来说工作正常 - 为什么有些用户无法通过标签请求?

使用速记值me而不是user.name@domain.com,将自动使用access token所属的用户。

最新更新