扩展撰写用户界面-缺少令牌

时间:2018-10-31 10:01:02

标签: google-apps-script gmail-addons

我尝试扩展撰写用户界面以添加来自外部服务器的附件,我首先尝试使用newUpdateDraftActionResponseBuilder()函数,但这只是向草稿正文中添加内容。 所以现在,我尝试以一种简单的draft.update()的方式获取草稿本身,但是当我尝试获取上一份草稿的信息时,却出现了以下错误:

  

“缺少用于授权的访问令牌。请求:   MailboxService.GetMessage”。

这是我的代码,错误在第二行:

var draft = GmailApp.getDrafts()[0];
var attachmentList = draft.getMessage().getAttachments();

您有获取此令牌的想法吗?

1 个答案:

答案 0 :(得分:0)

我想我找到了解决方案,此错误似乎是由于多个作用域之间的冲突引起的。删除不必要的作用域后,它就可以工作!

"oauthScopes": [
    "https://www.googleapis.com/auth/gmail.addons.execute",
    "https://mail.google.com/",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/gmail.addons.current.action.compose",
    "https://www.googleapis.com/auth/script.locale"
  ]