My goal is to understand whether I need to include the "access_token=" parameter when downloading a file from Google Drive.
This is a sub-question from my overall aim is of creating a Google Apps Script function to download a zip file directly to my local device.
This answer to a related question provides two solutions, the first from Tanaike adds the parameter to the URL:
+ "&access_token=" + ScriptApp.getOAuthToken()
and the second, from TheMaster includes it in the fetch headers:
UrlFetchApp.fetch(url, { headers: { Authorization: 'Bearer ' + ScriptApp.getOAuthToken() }, });
However, it is not required - the file downloads fine without it - so I'm wondering what purpose it serves and, therefore, if I should include it?
Access token is required when the file is private. Access token, as the name suggests, gives the owner of the token, access to a resource. If no special access is needed to access the file, access token is not required.