Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 拒绝访问::缺少授权的访问令牌。请求:MailboxService.GetThread。在Gmail线程中使用getMessages()时_Google Apps Script_Gmail_Gmail Addons - Fatal编程技术网

Google apps script 拒绝访问::缺少授权的访问令牌。请求:MailboxService.GetThread。在Gmail线程中使用getMessages()时

Google apps script 拒绝访问::缺少授权的访问令牌。请求:MailboxService.GetThread。在Gmail线程中使用getMessages()时,google-apps-script,gmail,gmail-addons,Google Apps Script,Gmail,Gmail Addons,我正在尝试获取已发送邮件中一个线程中的所有邮件。在下面的代码中,我可以以[GmailThread GmailThread..]的形式获取变量“mails”中发送的所有线程。还有邮件[0]。getId()提供邮件[0]的线程ID var mails = GmailApp.search('in:sent'); Logger.log(mails[0].getMessages()); 但是邮件[0]。getMessages()返回运行时错误 Access denied: : Missing acces

我正在尝试获取已发送邮件中一个线程中的所有邮件。在下面的代码中,我可以以[GmailThread GmailThread..]的形式获取变量“mails”中发送的所有线程。还有邮件[0]。getId()提供邮件[0]的线程ID

var mails = GmailApp.search('in:sent');
Logger.log(mails[0].getMessages());
但是邮件[0]。getMessages()返回运行时错误

Access denied: : Missing access token for authorization. Request: MailboxService.GetThread.
这是我包括的范围

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

现在我想要的是获取邮件[0]中的所有消息。

我在应用程序脚本GMail库中遇到了类似的错误。我转而使用GMail API服务。尝试使用它们,我没有遇到任何问题。

查看api文档,您可能缺少以下内容:

https://www.googleapis.com/auth/gmail.metadata

可能是用户被拒绝了权限?我试图使用Gmail API服务。它显示了此错误“URL未在脚本清单中列入白名单”。但此URL对于每条消息都是不同的,因为它还包含messageId。是否有一种方法可以动态地将messageId添加到此url,使其始终被列入白名单?不要使用URLFetchApp来查询API,而是使用JS库。此处提供的示例很少。请检查。