Why is this sample AppScript returning error: “Acc

2019-07-21 17:02发布

I received this error when attempting to run the sample Drive AppScript, even after authorizing the AppScript to access Drive. I have also tried hard-coding a folder ID and am receiving the same error.

The code is as follows:

function listFilesInFolder(id) {
  var folder = DriveApp.getFolderById(id);
  var contents = folder.getFiles();
  var file;
  var name;

  while(contents.hasNext()) {
    file = contents.next();
    name = file.getName();
    Logger.log(name);
  }
};

2条回答
祖国的老花朵
2楼-- · 2019-07-21 17:20

I was able to execute the script, after authentication, without any problems. Most probably, the DriveApp isn't activated in the Admin Console for you or your domain.

The following issue might be of interest (read comment #5), if the problem persist: Issue 4006

查看更多
来,给爷笑一个
3楼-- · 2019-07-21 17:26

In the Admin Console for you or your domain (admin.google.com) . section Drive - General settings - Enable "Allow users to install Google Drive Apps"

enter image description here

查看更多
登录 后发表回答