Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this sample AppScript returning error: "Access Denied: DriveApp?"

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);
  }
};
like image 408
toolshed Avatar asked Mar 20 '23 04:03

toolshed


2 Answers

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

like image 156
Edy Aguirre Avatar answered Mar 21 '23 18:03

Edy Aguirre


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

like image 37
Jacob Jan Tuinstra Avatar answered Mar 21 '23 16:03

Jacob Jan Tuinstra