How to sync ICloud Calendar?

Solution 1:

The answer by the OP is very useful but it's missing some key pieces. In particular how to determine the complete caldav URL by substituting the XXXX above.

Credit for my answer is due to this blog post (note: I use Thunderbird/Lightning as my caldav client but this is irrelevant) .

The format of an iCloud caldav URL is as follows:

https://pXX-caldav.icloud.com/<DSid>/calendars/<pGUID>

To determine the relevant parameters, first logon to your account on icloud.com, then launch the Firefox web debugging console (F12). The steps are depicted on the below screenshots which show the web debugging console below the iCloud calendar page. With the "Network" tab selected -step (1)- generate some traffic against desired calendars (eg: create a dummy appointment). Look for the corresponding POST (or GET) interactions.

  • The DSid parameter is some sort of numeric userID so it will be the same for multiple calendars/tasklists owned by the same account. Flip to "Parameters" -steps (2) & (3)- to reveal it. Determining 'dsid'
  • The pGUID varies from calendar to calendar (it could simply be "Home" or "tasks" if you don't have multiple calendars/tasklists setup). It can be peeked from the same interactions, but using the "Response" tab -steps (4) & (5)- You may have to drill down in the JSON structures a little to discover it. Determining 'pGUID'

That's all well and good. However it all stopped working quite recently and the comments at the bottom of the aforementioned blog post thankfully pointed to the source of the issue: since June 2017 Apple is migrating iCloud accounts to enforce app-specific passwords as a very sensible security measure. This means it's no longer possible to just use the main iCloud password for authentication when syncing calendars.

Once migration has happened to your iCloud account (you'll notice your calendar sync fails) the following steps are required:

  1. Enable 2-factor authentication on your iCloud account
  2. Generate an app-specific password and use that in your caldav client
  3. It's quite likely your caldav server will have changed as part of the migration (mine went from p03 to p40) so URLs need adjusting.

This news item (in German, use Google translate if necessary) has the background info on app-specific passwords.

BTW: I don't think calendars have to be shared in order to be accessed in this way.

Solution 2:

Here's a 2018 Update. If you want to use your iCloud calendar in Gnome Calendar you still need to install Evolution. After you added the calendar, you can remove Evolution.

  • Go to icloud.com and temporarily share a calendar to get the server URL and note it down somewhere (e.g. https://p12-caldav.icloud.com). Now deactivate the calendar sharing. If you don't do this, everyone can view this shared calendar!
  • Log into your Apple account and create an application-specific password for Evolution to access the calendars.
  • In Evolution create a new calendar, select CalDAV and enter the Server URL. Do not enter the full calendar URL, only the domain part (e.g. https://p12-caldav.icloud.com).
  • For the user enter your AppleId-Email and click find calendars. You will now be asked the password you created earlier (save it) and can select as many calendars as you like to be synced.