首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Google :您没有调用DriveApp.getFoldersByName的权限

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

Stack Overflow用户
提问于 2022-11-04 05:36:28
回答 2查看 28关注 0票数 0

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

代码语言:javascript
运行
复制
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中定义了以下内容

代码语言:javascript
运行
复制
{
  "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"
  ]
}

我得到了以下错误:

代码语言:javascript
运行
复制
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)

我做错了什么?任何帮助、暗示或建议都将不胜感激。

提亚

EN

Stack Overflow用户

发布于 2022-11-04 07:11:55

在这个例子中,似乎对我有用的是在函数上放置一个"Open“触发器来搜索文件夹。

代码语言:javascript
运行
复制
Deployment       Event                            Function
Head             From spreadsheet - On open       createOrAppendFile
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74312655

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档