Why is this sample AppScript returning error: “Acc

2019-07-21 17:20发布

问题:

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);
  }
};

回答1:

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



回答2:

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