Google Sheets:您没有权限调用DriveApp.getFoldersByName



我有一些代码正在尝试执行:

function createOrAppendFile(in_Folder, in_FileName, in_Content ) {
var fileName=in_FileName;
//var folderName=in_Folder;
var folderName="TRADEARCHIVE";
var content = in_Content;
// get list of folders with matching name
var folderList = DriveApp.getFoldersByName(folderName);  
if (folderList.hasNext()) {
// found matching folder
var folder = folderList.next();
// search for files with matching name
var fileList = folder.getFilesByName(fileName);
[... snip ...]

我在appscript.json中定义了以下内容

{
"timeZone": "America/Chicago",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"webapp": {
"executeAs": "USER_DEPLOYING",
"access": "ANYONE_ANONYMOUS"
},
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive"
]
}

我得到以下错误:

Nov 4, 2022, 12:28:53 AM    Error   Exception: You do not have permission to call DriveApp.getFoldersByName. Required permissions: (https://www.googleapis.com/auth/drive.readonly || https://www.googleapis.com/auth/drive)
at createOrAppendFile(Code:33:29)
at deleteRows(Code:173:11)
at onMyEdit(Code:390:29)

我做错了什么?如有任何帮助、提示或建议,我们将不胜感激。

TIA-

(在这种情况下(似乎对我有效的是放置一个";打开";触发器打开搜索文件夹的功能。

Deployment       Event                            Function
Head             From spreadsheet - On open       createOrAppendFile

您可以尝试

setSharing(DriveApp.Access.ANYONE_WITH_LINK,DriveApp.Permission.VIEW(;

将此添加到您的谷歌脚本

谢谢

相关内容

  • 没有找到相关文章

最新更新