very basic question on permission to call DriveApp.getFiles

1,932 views
Skip to first unread message

Raymond Hsu

unread,
Jun 19, 2022, 9:43:07 AM6/19/22
to Google Apps Script Community
I am new to apps script.

Have wrote a simple script to access all file names that I have access to in my account.

function Filenames() {
  /* var thisWorkbook = SpreadsheetApp.getActive();*/
 
  var files = DriveApp.getFiles();
  while (files.hasNext()) {
    var file = files.next();
    console.log(file.getName());
  }

  return;
}

when I invoke this function at one of the google sheet cell
=Filenames()

it returns an error of 
ErrorException: You do not have permission to call DriveApp.getFiles. Required permissions: (https://www.googleapis.com/auth/drive.readonly || https://www.googleapis.com/auth/drive) .

How can I resolve this issue ?

Thanks

 
 
 

Sheet1
Sheet2


 
Explore

Jonathan Butler

unread,
Jun 19, 2022, 2:14:53 PM6/19/22
to google-apps-sc...@googlegroups.com
You need to enable seeing the appscript.json in the view settings. Then you can add the permissions to the list manually. You most likely created a platform project. Once created app script no longer handles the permissions automatically. 

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/d5b821df-144e-423d-b8aa-87a53b90138en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages