How to get the file URL from file name in Google Sheets with correct Authorization via custom function/script
I would like to create a custom function that pulls a Drive URL from a file name in Google Sheets. So, using the code below: If I have a valid file name in cell A1 The function =getFile(A1) would return the URL When I run my script from within the script editor, the return value works. When I run the function getFile() from within my sheet, I get the error below. My code: function getFile(cell) { var filename = encodeURI(cell); var url = "https://www.googleapis.com/drive/v3/files?fields=files(id,name)&q=name+contains+'" + filename + "' and trashed=false"; var params = { method: "GET", headers: