fix(emacs): embed credentials in URL for org-caldav auth
Some checks failed
CI / check (push) Failing after 4m14s

url-http-basic-auth-storage approach wasn't working.
Now dynamically sets org-caldav-url with user:pass embedded.
This commit is contained in:
hermione
2026-01-24 17:52:02 -08:00
committed by John Ogle
parent 4853a18474
commit 0c484b6601

View File

@@ -95,14 +95,15 @@
;; Define sync wrapper before use-package (so keybinding works) ;; Define sync wrapper before use-package (so keybinding works)
(defun my/org-caldav-sync-with-rbw () (defun my/org-caldav-sync-with-rbw ()
"Run org-caldav-sync with credentials from rbw." "Run org-caldav-sync with credentials from rbw embedded in URL."
(interactive) (interactive)
(require 'org-caldav) (require 'org-caldav)
(let* ((password (my/get-rbw-password "nextcloud-caldav")) (let* ((password (my/get-rbw-password "nextcloud-caldav"))
(auth-string (base64-encode-string (format "johno:%s" password) t))) ;; Embed credentials in URL (url-encode password in case of special chars)
;; Set up URL basic auth cache (format: ((SERVER (PATH . BASE64-AUTH)))) (encoded-pass (url-hexify-string password)))
(setq url-http-basic-auth-storage (setq org-caldav-url
`(("nextcloud.johnogle.info:443" ("/" . ,auth-string)))) (format "https://johno:%s@nextcloud.johnogle.info/remote.php/dav/calendars/johno"
encoded-pass))
(org-caldav-sync))) (org-caldav-sync)))
(use-package! org-caldav (use-package! org-caldav
@@ -114,7 +115,7 @@
(:prefix ("a" . "agenda/calendar") (:prefix ("a" . "agenda/calendar")
:desc "Sync CalDAV" "s" #'my/org-caldav-sync-with-rbw))) :desc "Sync CalDAV" "s" #'my/org-caldav-sync-with-rbw)))
:config :config
;; Nextcloud CalDAV base URL ;; Nextcloud CalDAV base URL (credentials added dynamically by sync wrapper)
(setq org-caldav-url "https://nextcloud.johnogle.info/remote.php/dav/calendars/johno") (setq org-caldav-url "https://nextcloud.johnogle.info/remote.php/dav/calendars/johno")
;; Timezone for iCalendar export ;; Timezone for iCalendar export