GAS-ICS-Sync
GAS-ICS-Sync copied to clipboard
Error Code 403 when trying to process an .ics file stored in Google Drive
First of all, thank you very much for this awesome script 🥳
When trying to get a .ics file from Google Drive using a link that looks like this "https://drive.google.com/uc?export=download&id={id}", it works but it also fails every now and then and shows the following error message:
05.05.2022, 11:13:01 Error Exception: Request failed for https://drive.google.com returned code 403
at [unknown function](Helpers:80:37)
at callWithBackoff(Helpers:877:16)
at fetchSourceCalendars(Helpers:79:5)
at startSync(Code:156:21)
Seems like Google is blocking automated requests, see this and this
A solution could be to use the DriveAPI instead of UrlFetchApp but I am not sure about this.
Are there maybe other solutions to download and process the file consistently?
Many thanks in advance!
"403" is "Forbidden". Can you check to make sure that file is shared in Drive as "Anyone with the link"?
Yes, the link is set to "Anyone with the link". As I said sometimes it works but it fails occasionally with a 403 error code.
I am having the same issue on a calendar of mine, but my error is coming from the website that produces the calendar (not google). It only happens 5-10% of the time. But when it does happen, it deletes all the events in the calendar. Is there a way to force a stop if that error is produced? The log shows that it gets this error 3 times and then proceeds to sync a blank calendar (erasing my entire calendar). I wouldn't even mind if the sync stops after the first error.
Is there a way to force a stop if that error is produced? The log shows that it gets this error 3 times and then proceeds to sync a blank calendar (erasing my entire calendar). I wouldn't even mind if the sync stops after the first error.
You can add a check in code.gs line 160 to skip the sync if there is no valid source calendar.
if (responses.length == 0){
return;
}