I'm trying to integrate my application (Windows desktop app, and Web app) with mobile calendars.
My application is supposed to
- push new events to mobile calendars
- fetch events form mobile calendars
So far I managed to integrate with Google calendar (very easy, simple library + OAuth)
Now I want to do the same with iCloud calendar, but it's not that easy.
- In iCould settings I can make a calendar public. Than I can fetch events (as a iCalendar file), but I cannot push events.
- The cannot find any serious libraries for iCould calendar integration. I gave CalDav.Client a try, but need to provide CalDAV server url. which according to this should look like"
https://pXX-caldav.icloud.com/USER_ID/calendars/CALENDAR_ID
. I have no idea whatUSER_ID
andCALENDAR_ID
are and where to find them.
Any ideas?
PS
There is a workaround. I can ask user to create a Google accout along with a calendar and use it as a proxy. Integrate IPhone with Google calendar and form the other site integrate my application with Google calendar. It works, but the configuration is kind of tedious for the user.
EDIT
I tried following @hnh's instructions and discover CalDAV this way:
PROPFIND https://p42-caldav.icloud.com/ HTTP/1.1
Depth: 0
Prefer: return-minimal
Content-Type: application/xml; charset=utf-8
Host: p42-caldav.icloud.com
Content-Length: 102
<d:propfind xmlns:d="DAV:">
<d:prop>
<d:current-user-principal />
</d:prop>
</d:propfind>
The result was 401:
HTTP/1.1 401 Unauthorized
Content-Type: text/html;charset=utf-8
WWW-Authenticate: x-mobileme-authtoken realm="MMCalDav"
WWW-Authenticate: basic realm="MMCalDav"
Server: iCloudCalendarServer 15G33
Date: Tue, 26 Jan 2016 12:46:14 GMT
X-Responding-Server: mr26p42ic-ztdg05101801 17 a63660a6f7d1a25b5a7ed66dab0da843
X-Transaction-Id: c8dc19d4-c42a-11e5-8381-008cfaeb448c
Content-Length: 141
Strict-Transport-Security: max-age=31536000; includeSubDomains
<html><head><title>Unauthorized</title></head><body><h1>Unauthorized</h1><p>You are not authorized to access this resource.</p></body></html>
EDIT 2
Following further instructions I managed to authenticate, but still have problems with the requests from the article:
For:
<d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/">
<d:prop>
<d:displayname />
<cs:getctag />
</d:prop>
</d:propfind>
I get: (ctag
not found, and displayName
with value of "tmp" - which I don't recognize)
<?xml version='1.0' encoding='UTF-8'?>
<multistatus xmlns='DAV:'>
<response>
<href>/</href>
<propstat>
<prop>
<displayname>tmp</displayname>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
<propstat>
<prop>
<getctag xmlns='http://calendarserver.org/ns/'/>
</prop>
<status>HTTP/1.1 404 Not Found</status>
</propstat>
</response>
</multistatus>
And for this:
<c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
<d:prop>
<d:getetag />
<c:calendar-data />
</d:prop>
<c:filter>
<c:comp-filter name="VCALENDAR" />
</c:filter>
</c:calendar-query>
I get 400 Bad Request