Reputation: 9
I'm encountering an issue with Google Apps Script when trying to use DriveApp and GmailApp together. Here's the situation:
Code.gs
function test () {
let folder = DriveApp.getFolderById(FolderID);
let threads = GmailApp.search('is:starred')
let sheet = SpreadsheetApp.openById(sheetID)
console.log({
folder : folder,
threads : threads,
sheet : sheet
})
}
When these two services are called together in the same script, it throws the error.
error: "Exception: Authorization is required to perfom that action test @code.gs.2"
Troubleshooting steps I’ve tried:
Upvotes: -1
Views: 83
Reputation: 64032
It runs okay for me:
function test () {
let folder = DriveApp.getFolderById(gobj.globals.testfolderid);
let threads = GmailApp.search('is:starred')
let sheet = SpreadsheetApp.openById(gobj.globals.test1id)
Logger.log(JSON.stringify({
folder : folder.getName(),
threads : threads,
sheet : sheet.getName()
}))
}
Execution log
9:42:35 AM Notice Execution started
9:42:35 AM Info {"folder":"Testfolder","threads":[{},{},{},{},{}],"sheet":"Test1"}
9:42:37 AM Notice Execution completed
Upvotes: 0