1

我正在尝试获取 gmail 内容(正文),例如 Wrike(https://imgur.com/a/9h1ij),但出现上述错误。

“访问被拒绝::不允许完全访问邮件消息”

Logger.log(mail.getPlainBody());
4

3 回答 3

2

在没有看到您的代码的情况下,在我看来,您需要在
“appsscript.json”文件中包含正确的范围。

// This scope allows you to: 'View your email messages and settings'
"oauthScopes": ["https://www.googleapis.com/auth/gmail.readonly"]

// This scope gives you full access to your Gmail - 'Read, send, delete, and manage your email'
"oauthScopes": ["https://mail.google.com/"]

在此处查看范围文档:https ://developers.google.com/identity/protocols/googlescopes#gmailv1

于 2017-12-05T05:49:37.007 回答
0

找到了。我用“ https://www.googleapis.com/auth/gmail.addons.current.message.readonly ”替换了范围https://www.googleapis.com/auth/gmail.addons.current.message.metadata

注意:范围没有被添加,它被替换了。对于这两个条目,它似乎恢复到较低权限范围(元数据)而不是较高权限范围(只读)。

在这里获得了我需要的范围信息:https ://developers.google.com/gmail/add-ons/concepts/scopes

于 2018-09-28T12:53:32.100 回答
0

还可以尝试使用以下部分添加正文,

section.addWidget(CardService.newKeyValue()
.setTopLabel('Body')
.setContent(mail.getBody()));

为我工作。

于 2018-09-25T11:48:12.130 回答