dengste / org-caldav

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

Depricated google endpoint - new endpoint doesn't work #28

Closed wentasah closed 7 years ago

wentasah commented 11 years ago

Hello,

https://developers.google.com/google-apps/calendar/caldav/v2/guide says that https://www.google.com/calendar/dav endpoint is deprecated. One should use https://apidata.googleusercontent.com/caldav/v2/calid/events instead. I tried to

(setq org-caldav-url "https://apidata.googleusercontent.com/caldav/v2")

and modified the source like this:

diff --git a/org-caldav.el b/org-caldav.el
index cccb9bf..7241a26 100644
--- a/org-caldav.el
+++ b/org-caldav.el
@@ -322,7 +322,7 @@ Are you really sure? ")))

 (defun org-caldav-events-url ()
   "Return URL for events."
-  (if (string-match "google\\.com" org-caldav-url)
+  (if (string-match "google\\(usercontent\\)?\\.com" org-caldav-url)
       (concat org-caldav-url "/" org-caldav-calendar-id "/events/")
     (concat org-caldav-url "/" org-caldav-calendar-id "/")))

I ended up with an error:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  url-http-handle-authentication(nil)
  url-http-parse-headers()
  url-http-chunked-encoding-after-change-function(415 440 25)
  url-http-wait-for-headers-change-function(1 453 452)
  url-http-generic-filter(# "HTTP/1.1 401 Unauthorized
\nWWW-Authenticate: Bearer realm=\"https://www.google.com/accounts/AuthSubRequest\"
\nContent-Type: text/html; charset=UTF-8
\nDate: Tue, 24 Sep 2013 13:32:04 GMT
\nExpires: Tue, 24 Sep 2013 13:32:04 GMT
\nCache-Control: private, max-age=0
\nX-Content-Type-Options: nosniff
\nX-Frame-Options: SAMEORIGIN
\nX-XSS-Protection: 1; mode=block
\nServer: GSE
\nAlternate-Protocol: 443:quic
\nTransfer-Encoding: chunked
\n
\ne
\nLogin Required
\n0
\n
\n")
  accept-process-output(#)
  #[0 "\302\303\300@!)\207" [(#) inhibit-quit nil accept-process-output] 2 "\n\n(fn)"]()
  funcall(#[0 "\302\303\300@!)\207" [(#) inhibit-quit nil accept-process-output] 2 "\n\n(fn)"])
  url-retrieve-synchronously("https://apidata.googleusercontent.com/caldav/v2/wentasah@gmail.com/events/")
  url-http-options("https://apidata.googleusercontent.com/caldav/v2/wentasah@gmail.com/events/")
  url-dav-supported-p("https://apidata.googleusercontent.com/caldav/v2/wentasah@gmail.com/events/")
  (if (url-dav-supported-p (org-caldav-events-url)) nil (error "The URL %s does not seem to accept DAV requests" (org-caldav-events-url)))
  org-caldav-sync()
  call-interactively(org-caldav-sync record nil)
  command-execute(org-caldav-sync record)
  execute-extended-command(nil "org-caldav-sync")
  call-interactively(execute-extended-command nil nil)

Any idea why is that? With the old endpoint, everything works.

dengste commented 11 years ago

The new endpoint requires OAuth2 authentication. This is not supported in Emacs proper, though there exists a library for it in GNU ELPA.

I guess I could extend org-caldav to use this library, but after looking around for roughly an hour on Google, using the new endpoint with OAuth2 isn't straightforward at all. It seems I have to register org-caldav as an application, which also for some reason requires giving Google my cell phone number, which I won't do. Also, the application is restricted to limits like 5 requests per second, which will lead to errors during the initial sync. Unless I pay for it, of course...

I find it pretty ridiculous that I should have to jump through hoops like this just to sync a calendar, especially since I don't use it. So it seems that when the old endpoint stops working, this is it for Google Calendar sync, unless someone else wants to implement it.

d12frosted commented 8 years ago

You are not required to create application. It's better to ask users that want to use OAuth2 to create their own applications if they wish to use new endpoint. So 5 requests per second is good enough for almost all users.

As example, there is org-gcal that works with new end point.

sje30 commented 7 years ago

Is anyone else interested in merging org-gcal functionality into org-caldav?

dengste commented 7 years ago

Since Google does no longer require cell phone numbers for registering a CalDAV application, I've added that functionality. Every user will still need to register its own application with Google, though (see README).