Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README is out of date #213

Open
megodoonch opened this issue Nov 22, 2022 · 13 comments
Open

README is out of date #213

megodoonch opened this issue Nov 22, 2022 · 13 comments

Comments

@megodoonch
Copy link

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 Retrieving OAuth 2.0 tokens via Out Of Band redirect_uri is deprecated #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:\[email protected]\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
Copy link
Collaborator

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 Allow multiple accounts #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
Copy link

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
Copy link

sophom commented Dec 27, 2022

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
Copy link

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
Copy link

sophom commented Dec 27, 2022

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
Copy link

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
Copy link

deen1 commented Jan 4, 2023

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
Copy link
Author

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
Copy link

malleyeno commented Jan 10, 2023

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
Copy link

deen1 commented Feb 6, 2023

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
Copy link
Author

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
Copy link

Trevoke commented Mar 6, 2023

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
Copy link
Author

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)

telotortium pushed a commit that referenced this issue Feb 13, 2024
* Doc: OOB warn fix, oauth2-auto.plist issue steps

* Doc: org-capture-template snippet in readme

* Doc: org-gcal-sync does not post new events

* Doc: Sync at regular times snippet

* Rebase to master, go to LF instead of CRLF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants