I'm trying to create a basic script on a 12-hour timer trigger that loops through each of my Google Calendars by their ICAL URL, and downloads the ICAL for a folder on my Google Drive (for backup purposes). It throws this error 

```
"No item with the given ID could be found, or you do not have permission to access it. (line 23, file "Code")"   (Line #23 is var folder... )

```

Running the script does download and save the ICAL file on the first run through the loop (and if I manually pass in each unique ICAL URL one at a time), but the error then terminates the loop. Seeing as how I've authorized access already and am the owner of everything here, I'm not sure what else I need.

```
var calendarsToSave = [
                     "https://calendar.google.com/calendar/ical/inXXXXXXX.com/privateXXXX/basic.ics",
                     "https://calendar.google.com/calendar/ical/XXXXX.com_XXXXXXup.calendar.google.com/private-XXXXXXX/basic.ics"
                    ]; 

var folder = '123xxxxxxxxv789';  // my gdrive folder 

function downloadFile(calendarURL,folder) {

   var fileName = "";
   var fileSize = 0;

  for (var i = 0; i < calendarsToSave.length; i++) { 

    var calendarURL = calendarsToSave[i];

    var response = UrlFetchApp.fetch(calendarURL, {muteHttpExceptions: true});
    var rc = response.getResponseCode();

    if (rc == 200) {
      var fileBlob = response.getBlob()

      var folder = DriveApp.getFolderById(folder);   // << returns a permissions error thus terminating the for loop
      var file = folder.createFile(fileBlob);
      fileName = file.getName();
      fileSize = file.getSize();

    }

    var fileInfo = { "rc":rc, "fileName":fileName, "fileSize":fileSize };
    return fileInfo;    

  }  // end for loop

}

```