Google Apps脚本需要已授予的权限 [英] Google apps script requires permissions that are already granted
问题描述
这是有问题的功能
function GetResponseDate(confirmation) {
var threads = GmailApp.search(confirmation);
var initialResponse;
if(threads.length!=0){
initialResponse = threads[0].getMessages()[0].getDate();
}
else{
initialResponse = "none";
}
return initialResponse;
}
这是清单:
{
"oauthScopes":[
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.addons.current.message.readonly",
"https://www.googleapis.com/auth/gmail.addons.current.message.action",
"https://www.googleapis.com/auth/gmail.modify"
],
"timeZone": "America/Los_Angeles",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER"
}
实现只是
= GetResponseDate("12345")
在一个单元格内.
我已授予所有已弹出的权限请求(无论是默认权限,还是我在清单文件中添加的其他权限),但仍然出现工作表错误:
I've granted all of the permissions requests that have popped up (whether by default, or the additional ones I added in the manifest file), but I still get the sheets error:
The script does not have permission to perform that action. Required permissions: (https://www.googleapis.com/auth/gmail.readonly || https://www.googleapis.com/auth/gmail.addons.current.message.readonly || https://www.googleapis.com/auth/gmail.addons.current.message.action || https://www.googleapis.com/auth/gmail.modify || https://mail.google.com/) (line 3).
推荐答案
在艾伦·威尔斯(Alan Wells)和塔奈克(Tanaike)的支持下(尽管由于我的帐户是新的,所以我无法对其进行投票).
Answered by Alan Wells and Tanaike (though I can't upvote them because my account is new).
解决方案是:单个单元格公式无法请求权限,而正确的请求权限为https://mail.google.com/
.一种解决方法是:将脚本作为菜单项而不是在单元格中执行(尽管需要对其进行修改以解释并输出到单元格).
Solution is: individual cell formulas can't request permissions, and the correct permission to request is https://mail.google.com/
. One workaround is: execute script as a menu item instead of within a cell (though it needs to be modified to interpret and output to cells).
这篇关于Google Apps脚本需要已授予的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!