dengste / org-caldav

Caldav sync for Emacs orgmode
GNU General Public License v3.0
718 stars 105 forks source link

iCloud integration #245

Open smallstepman opened 2 years ago

smallstepman commented 2 years ago

I'm trying to setup integration with iCloud calendars. here is relevant part of my Doom Emacs config:

(use-package! org-caldav
  :after org
  :config
  (setq org-caldav-url "https://pXX-caldav.icloud.com:443/XXXXXXXXXX/calendars")
  (setq org-caldav-calendars
  '((:calendar-id "XXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
     :files ("~/org/work.org")
     :inbox "~/org/fromwork.org")
    (:calendar-id "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
     :files ("~/org/sports.org" "~/org/play.org")
     :inbox "~/org/fromstuff.org"))))

With my credentials (apple_id & app_specifict_generated_password) I was able to follow this guide and obtain my principal_id and calendar_ids, therefore I belive there is nothing wrong with credentials.

When I run M-x org-caldav-sync, minibuffer asks for my Username [for MMCalDav] (which I provide in format USERNAME@icloud.com) then for password. When I enter incorrect password I get this HTTP error

HTTP/1.1 401 Unauthorized
Server: AppleHttpServer/f6f00135a2e1
Date: Tue, 19 Oct 2021 02:24:11 GMT
Content-Length: 0
Connection: keep-alive
X-Apple-Jingle-Correlation-Key: XXXXXXXXXXXXXXXXXXXXXXXXX
apple-seq: 0
apple-tk: false
Apple-Originating-System: UnknownOriginatingSystem
X-Responding-Instance: caldavj:XXXXXXX:XXXXXXXX-XXXXXXXXX:XXXX:XXXXXXXXX:XXXXXXXXXX
WWW-Authenticate: Basic realm="MMCalDav"
WWW-Authenticate: X-MobileMe-AuthToken realm="MMCalDav"
Strict-Transport-Security: max-age=31536000; includeSubDomains;
via: XXXXXXXXXXXXXXXXXXXXXXXXX
X-Apple-Request-UUID: XXXXXX-XXXX-XXXX-XXXXXXXX
access-control-expose-headers: X-Apple-Request-UUID,Via
X-Apple-Edge-Response-Time: 134

when I enter correct password, I get following error

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p "")
  org-caldav-check-connection()
  #f(compiled-function () #<bytecode 0x172e0b3520d8cd25>)()
  funcall(#f(compiled-function () #<bytecode 0x172e0b3520d8cd25>))
  (let ((org-caldav-inbox '"~/org/fromwork.org") (org-caldav-files '("~/org/work.org")) (org-caldav-calendar-id '"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")) (funcall '#f(compiled-function () #<bytecode 0x172e0b3520d8cd25>)))
  eval((let ((org-caldav-inbox '"~/org/fromwork.org") (org-caldav-files '("~/org/work.org")) (org-caldav-calendar-id '"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")) (funcall '#f(compiled-function () #<bytecode 0x172e0b3520d8cd25>))))
  org-caldav-sync-calendar((:calendar-id "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" :files ("~/org/work.org") :inbox "~/org/fromwork.org"))
  org-caldav-sync()
  funcall-interactively(org-caldav-sync)
  call-interactively(org-caldav-sync record nil)
  command-execute(org-caldav-sync record)
  counsel-M-x-action("org-caldav-sync")
  #f(compiled-function (x) #<bytecode -0x20a881f79ff60e3>)("org-caldav-sync")
  ivy-call()
❯ emacs --version   
GNU Emacs 28.0.50
ChristopherKonkel commented 1 year ago

@smallstepman I know this ticket is quite old, but were you able to solve this issue or found an alternative? I was trying to setup this exact workflow but ended up with the same error.

smallstepman commented 1 year ago

No, but I haven’t really tried to solve this issue. The only alternative I’m aware of is to one-way sync via google calendar, but that also doesn’t work out of the box (requires usage of branch with a oauth fix).

I’m not really familiar with iCloud auth flow, but perhaps this repo could serve as an inspiration https://github.com/MauriceConrad/iCloud-API/blob/master/resources/apps/Calendar.js

Let me know if you’d like to try to figure this out together. I don't have the bandwidth to deep dive this issue alone at the moment, but if we could spread the load, I can try taking a stab at it.

EasyHard commented 2 weeks ago

I managed make this work after making some changes to compensate icloud's CalDav behaviors. Probably not the most clean way since I know little about CalDav and elisp. https://github.com/dengste/org-caldav/pull/305