Ubuntu – How to sync ICloud Calendar

caldavcalendar

I want to be able to acces the calendars I have on my ICloud account without having to use a web-browser, and possibly offline.

How can I sync my calendars from ICloud with some calendar client on Ubuntu?

Best Answer

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.