Home > database >  GoogleJsonResponseException: API call with error: Login Required
GoogleJsonResponseException: API call with error: Login Required

Time:07-15

I made a script using the enter image description here

Error message is like below : GoogleJsonResponseException: API call to drive.drives.list failed with error: Login Required.

I guess it's some authentification & authorisation to ask before using the sheet.

Unfortuantly I have no idea how to request that ! I read enter image description here

I automatically get the information of the Sheet and get a list of my Drive files:

function onOpen () {
var ui= SpreadsheetApp.getUi();
  ui.createMenu('Adv Menu').addItem('Drive', 'getMyFilesFromDrive').addToUi();
}


function getMyFilesFromDrive() {
 var myFiles = DriveApp.searchFiles('"me" in owners');
 var sheet = SpreadsheetApp.getActive().getSheetByName("Files");
 sheet.clear();
 var rows = [];
 rows.push(["ID", "Name", "Url"]);
 while(myFiles.hasNext()) {
   var file = myFiles.next();
   if(file != null) {
     rows.push([file.getId(), file.getName(), file.getUrl()]);
   }
 }
 sheet.getRange(1,1,rows.length,3).setValues(rows);
}

It would also write it directly to my Sheet. Feel free to review it and use it.

You can also Draw a button (Inserting a Google Drawing) over the Sheet and assign a script:

enter image description here

Reference:

  • Related