I’m just starting out with Google Apps Script and the Drive API. I’m trying to use the duplicate file feature but keep running into authentication errors. Every time I attempt to execute the copy operation, I get prompted that authentication is needed. Can someone point me to a working example or tutorial that shows how to properly set up authentication between Google Apps Script and the Drive API? I’ve been searching but can’t find clear documentation on this specific setup. Any help would be greatly appreciated!
also check your api version - auth often fails when there’s a version mismatch between what yer calling and what’s actually available. i’d try the built-in driveApp methods first instead of the advanced drive service. they handle auth automatically n are way easier if ur just starting out.
I experienced a similar issue when first working with the Drive API and Google Apps Script. The authentication errors usually arise from not having the correct OAuth scopes defined in the appsscript.json manifest file. You should ensure that the Drive API scope is included under oauthScopes in your manifest. Additionally, check that you’re properly using DriveApp.getFileById() and that your script has the necessary permissions to access your Drive files. Typically, Google will prompt for permissions when you run it for the first time. If issues persist, try clearing the script’s authorization and re-executing it to refresh the OAuth token, as that resolved my problem.