# \[SOLVED\] Apple icloud CalDav connection

**URL:** <https://community.openhab.org/t/solved-apple-icloud-caldav-connection/32510>\
**Category:** Bindings\
**Created:** [July 31, 2017, 12:20pm UTC](https://community.openhab.org/t/solved-apple-icloud-caldav-connection/32510 "2017-07-31T12:20:03Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Andrew\_Pawelski](https://community.openhab.org/user_avatar/community.openhab.org/andrew_pawelski/32/85454_2.png) [@Andrew\_Pawelski](https://community.openhab.org/u/Andrew_Pawelski)\
**Post date:** [August 1, 2017, 3:27am UTC](https://community.openhab.org/t/solved-apple-icloud-caldav-connection/32510/6 "2017-08-01T03:27:37Z")

</div>

OK to so to do this via cURL:

Log into your Apple account at [appleid.apple.com](http://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 :

```auto
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/](https://caldav.icloud.com/347723822/principal/)

Next run this (replacing your numeric ID)

```auto
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](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):

```auto
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:

```auto
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

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

```

Once you have this, glue it together:

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

```

And that is your calDAV URL

Now in caldavio.cfg

```php
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

```javascript
caldavPersonal:usedCalendars=AJ

```

Then a few items

```csv
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

```php
Text item=OfficeCalName0 
Text item=OfficeCalTime0

```

Done!

---

_[View the full topic](https://community.openhab.org/t/solved-apple-icloud-caldav-connection/32510)._
