[SOLVED] Apple icloud CalDav connection

OK to so to do this via cURL:

Log into your Apple account at appleid.apple.com. Confirm your login by entering the two-factor identification code sent to your primary device. Once logged in, look for the section in your Apple ID control panel labeled “Security” and click on “Generate Password”

When prompted, label the app-specific password whatever you want eg “OpenHab” and click “Create”.

Apple will provide you with a randomly generated alphanumeric string in the format xxx-xxxx-xxxx-xxxx. Highlight and copy the password and keep it somewhere safe.

Next open a console that can run cURL

run this (replacing $APPLEID with your own Apple ID :

curl -s -X PROPFIND -u "$APPLEID" -H "Depth: 0"  --data "<propfind xmlns='DAV:'><prop><current-user-principal/></prop></propfind>"  https://caldav.icloud.com/

When propmted for creentials, enter in the app-specific password

You should get a response and it shows you the URL of your account record, it looks something like https://caldav.icloud.com/347723822/principal/

Next run this (replacing your numeric ID)

curl -s -X PROPFIND -u "$APPLEID" -H "Depth: 0"  --data "<propfind xmlns='DAV:' xmlns:cd='urn:ietf:params:xml:ns:caldav'><prop><cd:calendar-home-set/></prop></propfind>" 
 https://caldav.icloud.com/347723822/principal/

This gives you the reference to the cluster the actual calendars lives on, it looks something like https://p22-caldav.icloud.com:443/347723822/calendars

You can list all the calendars from your icloud account by running (replacing with your output from above):

curl -s -X PROPFIND -u "$APPLEID" -H "Depth: 1"  --data "<propfind xmlns='DAV:'><prop><displayname/></prop></propfind>"  https://p42-caldav.icloud.com:443/347723822/calendars/ | grep displayname

then strip off the grep to show all info about each calendar:

curl -s -X PROPFIND -u "$APPLEID" -H "Depth: 1"  --data "<propfind xmlns='DAV:'><prop><displayname/></prop></propfind>"  https://p42-caldav.icloud.com:443/347723822/calendars/ 

You may need to up your history buffer depending on the number of calendars you have.

You are looking for the href value if the calendar you are after eg

<href>/1317873642/calendars/086e6106-1c0d-4301-a99d-5c5ebbcc5079/</href>

Once you have this, glue it together:

https://p42-caldav.icloud.com:443/347723822/calendars/086e6106-1c0d-4301-a99d-5c5ebbcc5079/

And that is your calDAV URL

Now in caldavio.cfg

caldavio:AJ:url=https://p42-caldav.icloud.com:443/347723822/calendars/086e6106-1c0d-4301-a99d-5c5ebbcc5079/
caldavio:AJ:username=myicloudusername
caldavio:AJ:password=myappspecifipass
caldavio:AJ:reloadInterval=60
caldavio:AJ:preloadTime=20000
caldavio:AJ:disableCertificateVerification=false
caldavio:timeZone=Australia/Adelaide

and in calDAVPersonal.cfg

caldavPersonal:usedCalendars=AJ

Then a few items

String OfficeCalName0   "Next Up [%s]"     <calendar>  { caldavPersonal="calendar:AJ type:EVENT eventNr:1 value:NAME" } 
DateTime OfficeCalTime0 "Starts [%1$tT, %1$td.%1$tm.%1$tY]"         <calendar>  { caldavPersonal="calendar:AJ type:EVENT eventNr:1 value:START" }

and on the sitemap

Text item=OfficeCalName0 
Text item=OfficeCalTime0

Done!

5 Likes