kidd / org-gcal.el

Org sync with Google Calendar. (active maintained project as of 2019-11-06)
432 stars 47 forks source link

README is out of date #213

Open megodoonch opened 1 year ago

megodoonch commented 1 year ago

This works again!! So I think there are some instructions in the README that are no longer correct:

  1. No longer a problem, right? "WARNING: The steps described below stopped working on 28.02.2022 when Google deprecated the ability to retrieve OAuth 2.0 tokens via out-of-band redirect_uri. Please refer to https://github.com/kidd/org-gcal.el/issues/191 for more background and to track progress on resolving this issue."

  2. Is this still true? "There’s no support for multiple accounts."

  3. It might be helpful to clarify that the first time you make an event in orgmode, you have to use org-gcal-post-at-point; until that happens, org-gcal-sync doesn't know about it (right?) here: "The command org-gcal-sync does what org-gcal-fetch does, but also runs org-gcal-post-at-point on all events that you’ve edited in Org mode to update the corresponding events in Google Calendar."

  4. On Reddit, @telotortium provided a really helpful sample capture template; if you're updating the README you might want to add it:

(setq org-capture-templates
      `(("a" "Appointment" entry (file ,(concat org-directory "/gcal.org"))
        "* %?\n:PROPERTIES:\n:calendar-id:\tFirst.Last@gmail.com\n:END:\n:org-gcal:\n%^T--%^T\n:END:\n\n" :jump-to-captured t)))
  1. While you're at it, if anyone can suggest hooks for automating the sync, that would be awesome!

Thank you for providing this! I've been periodically trying to sync my google calendar and orgmode for years!

telotortium commented 1 year ago

Hi @megodoonch :

  1. No, that's no longer a problem. I'll update the README soon.
  2. True for now, but it should be possible to support multiple accounts with a little refactoring - follow https://github.com/kidd/org-gcal.el/issues/199. Multiple calendars shared to the same account have been supported for a while.
  3. Yes, you need to use org-gcal-post-at-point to create an event. I'll try to see how to update the README to make that clear.
  4. Noted
  5. You can try something like this:
;; Run ‘org-gcal-sync’ regularly not at startup, but at 8 AM every day,
;; starting the next time 8 AM arrives.
(run-at-time
 (let* ((now-decoded (decode-time))
        (today-8am-decoded
         (append '(0 0 8) (nthcdr 3 now-decoded)))
        (now (encode-time now-decoded))
        (today-8am (encode-time today-8am-decoded)))
   (if (time-less-p now today-8am)
       today-8am
     (time-add today-8am (* 24 60 60))))
 (* 24 60 60)
 (defun my-org-gcal-sync-clear-token ()
   "Sync calendar, clearing tokens first."
   (interactive)
   (require 'org-gcal)
   (when org-gcal--sync-lock
     (warn "%s" "‘my-org-gcal-sync-clear-token’: ‘org-gcal--sync-lock’ not nil - calling ‘org-gcal--sync-unlock’.")
     (org-gcal--sync-unlock))
   (org-gcal-sync-tokens-clear)
   (org-gcal-sync)
   nil))

You can also just run org-gcal-sync every few hours using org-gcal-sync using run-at-time. I call org-gcal-sync-tokens-clear every day so that all events are synced, but for more frequent syncs, the sync tokens really help with cutting down the sync time.

tillheilmann commented 1 year ago

Thanks for all the work you're putting into this!

org-gcal stopped working for me a few weeks ago. Having set up a new Oauth client ID (following the respective instructions in README.org), calling org-gcal-sync does not get me past Google's verification page. All the required packages should be installed and up to date. Any idea what I am doing wrong? Thanks in advance!

Bildschirmfoto 2022-12-21 um 09 33 15

sophom commented 1 year ago

Thanks for all the work you're putting into this!

org-gcal stopped working for me a few weeks ago. Having set up a new Oauth client ID (following the respective instructions in README.org), calling org-gcal-sync does not get me past Google's verification page. All the required packages should be installed and up to date. Any idea what I am doing wrong? Thanks in advance!

Bildschirmfoto 2022-12-21 um 09 33 15

To get through the "Access blocked" message, now you have to enter yourself (well... your gmail address) as a "Test user" for the "Emacs" app in the apps "OAuth consent screen". What a pain the rear this has become. Definitely set the "(setq plstore-cache-passphrase-for-symmetric-encryption t)" so you don't continually get prompted for your passphrase for the entry.

It ends up working after that. and it's pretty nice.

tillheilmann commented 1 year ago

Okay, thanks! Added myself as "Test user" and now I get through Google's consent screen. Next issue, though, and I am not sure this is the right place to ask about it (first, Emacs asks me Buffer plstore /Users/till/.emacs.d/oauth2-auto.plist modified; kill anyway? (y or n) and then, after answering n since no such buffer exists, tells me GPG error: "Encrypt failed", "Exit").

sophom commented 1 year ago

Hmm... I don't know how much help I can be here because I'm not sure what's going on but I think you want that buffer to be saved. It should happen on its own. Do you know if you're creating that file for the first time (does plstore ask you twice for your passphrase)? If so, this is a new buffer and it needs to be saved. Does it not exist in your buffer list? If it does, save it. If it doesn't, does the file itself exist in your filesystem? If the file exists, maybe you can exit emacs (completely... kill the emacs server if you're running it), restart emacs and try syncing gcal again (I know you shouldn't have to do this but it might work).

If the file already existed before you started using gcal then you must make sure you enter whatever passphrase you set up the first time you created that plstore file.

tillheilmann commented 1 year ago

Yes, seems to be a somewhat messy issue. Originally, neither file nor buffer /Users/till/.emacs.d/oauth2-auto.plist existed. After shutting down and restarting Emacs, the file showed up and also the corresponding buffer. When running org-gcal-sync now, the browser opens Google's consent page and I can click through until I get a new page in the browser saying Authentication token successfully obtained by Emacs! You may close this page now. However, Emacs again asks me Buffer plstore /Users/till/.emacs.d/oauth2-auto.plist modified; kill anyway? (y or n) and then tells me deferred error : (epg-error "Encrypt failed" "Exit"). I am not being prompted for any passphrase. Hm...

deen1 commented 1 year ago

This might be the wrong place to raise the following, but I believe my issue is related to what's described here:

I'm having a few issues with continually having to authenticate org-gcal and type in a passphrase.

I was using an older version of the package until recently as I think I'd set up org-gcal in testing/legacy mode before, but decided to upgrade.

I am using (setq plstore-cache-passphrase-for-symmetric-encryption t) as suggested, but even then I keep having to type a passphrase at least once a day, and then re-authenticate org-gcal about every other day after being redirected to my browser.

Here is the relevant part of my config:

(use-package org-gcal
  :ensure t
  :defer t
  :config
  (setq org-gcal-client-id "******"
    org-gcal-client-secret "*****"
    org-gcal-file-alist '(("*****@gmail.com" .  "~/Org/gcal.org")
                  ("*****.calendar.google.com" . "~/Org/gcal-2.org")))
  (org-gcal-reload-client-id-secret)

  (setq plstore-cache-passphrase-for-symmetric-encryption t)
  (add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))
  (add-hook 'org-save-all-org-buffers (lambda () (org-gcal-sync) ))

  ;; Added to stop org-agenda from freezing after sync is locked
  (add-hook 'org-agenda-mode-hook (lambda () (org-gcal--sync-unlock)) 100) )

I don't have any specific oauth2-auto settings in my config.

megodoonch commented 1 year ago

This might be the wrong place to raise the following, but I believe my issue is related to what's described here:

I'm having a few issues with continually having to authenticate org-gcal and type in a passphrase.

I was using an older version of the package until recently as I think I'd set up org-gcal in testing/legacy mode before, but decided to upgrade.

I am using (setq plstore-cache-passphrase-for-symmetric-encryption t) as suggested, but even then I keep having to type a passphrase at least once a day, and then re-authenticate org-gcal about every other day after being redirected to my browser.

Here is the relevant part of my config:

(use-package org-gcal
  :ensure t
  :defer t
  :config
  (setq org-gcal-client-id "******"
  org-gcal-client-secret "*****"
  org-gcal-file-alist '(("*****@gmail.com" .  "~/Org/gcal.org")
                ("*****.calendar.google.com" . "~/Org/gcal-2.org")))
  (org-gcal-reload-client-id-secret)

  (setq plstore-cache-passphrase-for-symmetric-encryption t)
  (add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))
  (add-hook 'org-save-all-org-buffers (lambda () (org-gcal-sync) ))

  ;; Added to stop org-agenda from freezing after sync is locked
  (add-hook 'org-agenda-mode-hook (lambda () (org-gcal--sync-unlock)) 100) )

I don't have any specific oauth2-auto settings in my config.

I have this problem too.

malleyeno commented 1 year ago

However, Emacs again asks me Buffer plstore /Users/till/.emacs.d/oauth2-auto.plist modified; kill anyway? (y or n) and then tells me deferred error : (epg-error "Encrypt failed" "Exit")

(apologies if this is off-topic, this is the only place where I saw this issue being brought up)

I ran into that issue as well when I did my initial set up. The buffer would not be accessible, and no plist file was being made so the fetch command did not work.

I managed to fix it by manually creating an empty oauth2-auto.plist file in my USER-EMACS-DIRECTORY then running org-gcal-fetch again. However, I still do need to use a password since I run into the same (epg-error "Encrypt failed" "Exit") if I try to leave the password empty.

deen1 commented 1 year ago

To anyone following my comment above, I fixed the associated problem where I kept having to type a passphrase on top of re-authenticating, after seeing it described in issue #217. Reading the discussion there, I found that my plstore-passphrase-alist was also nil, and changed (setq plstore-cache-passphrase-for-symmetric-encryption t) to use setq-default as mentioned, as well as adding (setq epg-pinentry-mode 'loopback). Now I don't get the passphrase prompt anymore, but I still have to re-authenticate with Google every couple of days.

megodoonch commented 1 year ago

To anyone following my comment above, I fixed the associated problem where I kept having to type a passphrase on top of re-authenticating, after seeing it described in issue #217. Reading the discussion there, I found that my plstore-passphrase-alist was also nil, and changed (setq plstore-cache-passphrase-for-symmetric-encryption t) to use setq-default as mentioned, as well as adding (setq epg-pinentry-mode 'loopback). Now I don't get the passphrase prompt anymore, but I still have to re-authenticate with Google every couple of days.

Sadly, this isn't working for me! I'm thinking my Emacs is automatically using GPG for passwordy things, and since I don't know what that is, nor how to stop it, none of the plstore fixes are helping.

This issue has become a kind of a generalised help forum; is that okay?

Trevoke commented 1 year ago

Speaking as someone who's waiting for the README to be updated to start using this again, I would rather this issue remain specifically focused on, well, getting the README up to date :D

megodoonch commented 1 year ago

Speaking as someone who's waiting for the README to be updated to start using this again, I would rather this issue remain specifically focused on, well, getting the README up to date :D

Reasonable! As the person who opened this issue, is there something technical I should do, or should I just request here in words that any further discussion of these other issues be moved to other/new issues? (I'm new to using GitHub collaboratively)