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

> 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") #236

Open
Q-Tran opened this issue Apr 20, 2023 · 9 comments

Comments

@Q-Tran
Copy link

Q-Tran commented Apr 20, 2023

I have the same problem here, and I created an empty oauth2-auto.plist file in my user-emacs directory. I am still getting the same error and do not know where to "use a password" as referenced in the solution given below.

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.

Originally posted by @malleyeno in #213 (comment)

@telotortium
Copy link
Collaborator

I recently discovered that plstore can use asymmetric GPG keys from gpg-agent and wrote some instructions on how to use it. It at least doesn't prompt me for passwords so much. Try setting this up and see if it works? #239

@dmitrym0
Copy link

dmitrym0 commented May 23, 2023

I recently discovered that plstore can use asymmetric GPG keys from gpg-agent and wrote some instructions on how to use it. It at least doesn't prompt me for passwords so much. Try setting this up and see if it works? #239

@telotortium I've followed your directions and I'm still showing this error. Additionally, I'm showing a gpg error now as well:

Saving file /Users/dmitrym/.emacs.d/oauth2-auto.plist...
Wrote /Users/dmitrym/.emacs.d/oauth2-auto.plist
deferred error : (wrong-type-argument stringp ("0CB..."))

I do have this as well

#+begin_src elisp
  (require 'plstore)
  (add-to-list 'plstore-encrypt-to '("0CB...."))
#+end_src

When I invoke gcal-sync, I get asked for the oauth repeatedly and then Emacs just seems to hang. Any idea what might be going on?

@telotortium
Copy link
Collaborator

@dmitrym0 I think this is a bug with GnuPG 2.4.1 and greater, or at least Emacs' use of it. On #238 (comment) someone solved this issue by downgrading GPG to 2.4.0 or below, and that worked for me as well to solve that issue.

@dmitrym0
Copy link

@telotortium thanks that worked!

@tiktaaliki
Copy link

tiktaaliki commented Jul 3, 2023

Hi, I'm not sure if I should create a new issue or not, since this is still listed as open. If I should open a new request instead of writing here, please let me know!

When I run org-gcal-sync, I get deferred error : (epg-error "Decryption failed" "")

In contrast to dmitrym0, downgrading GPG to 2.4.0 or below did not resolve the issue for me.

I also tried following the instructions to use plstore and asymmetric keys, but got stuck at this step:

  • Set up pinentry for gpg-agent, so that the password to decrypt the GPG key is stored in the system keychain. For example, on macOS you can follow these instructions.

I'm not sure what this means. Pinentry is installed on my machine and found this https://www.gnupg.org/related_software/pinentry/index.html but I am not very technically savvy and do not know how to set up pinentry for gpg-agent. I am on Manjaro.

It's possible that executing these steps and then downgrading would be effective, so any help on this last point would be appreciated, thank you!

@dmitrym0
Copy link

@tiktaaliki I went through the instructions one more (because I forgot my gpg password) and they seem to work fine.

Which step did you have problems with regarding setting up pin entry?

@aliyss
Copy link

aliyss commented Jul 21, 2023

Same issue on my machine. I thought I might summarize.

Used oauth2-auto (but the process and result is the same):

    (require 'oauth2-auto)
    
    (setq
        oauth2-auto-google-client-id "[REDACTED]"
        oauth2-auto-google-client-secret "[REDACTED]"
    )

    ;; testing
    (oauth2-auto-access-token-sync oauth2-auto-google-client-id 'google)

The code correctly opens the browser page and the process works well with a success message on the localhost page.
Afterwards it hangs a bit on the "Contacting host: oauth2.googleapis.com:443".
And at the end I receive the same error message as described above.

Specs:

  • Arch
  • Emacs 30.0.50
  • GPG 2.4.0

I'll try out the asymetric gpg-agent stuff later on (maybe tmrw) and report back if that worked out in my case. @tiktaaliki

@aliyss
Copy link

aliyss commented Jul 22, 2023

Alright... So it works for me now. I changed a few things, so I'm not sure which ones worked out. Please keep in mind I started with emacs just this week. I don't really know what I'm doing.

Specs:

  • Arch
  • Emacs 30.0.50
  • GPG 2.4.0

In your ~/.gnupg/gpg-agent.conf (create if not exists) add the following:

# I'm assuming this is what made it work.
allow-loopback-pinentry

In your terminal:

gpgconf --reload gpg-agent

In your emacs config add the following:

    
    (require 'epa-file)
    ;; And then this setting probably is also the winner.
    (setq epg-pinentry-mode 'loopback)
    (epa-file-enable)
    
    ;; I don't know if this is necessary. I removed it again.
    ;; Essentially it is the path to the downgrade package I used.
    (setq epg-gpg-program "~/Downloads/gnupg-2.4.0/bin/gpg")

    ;; No clue if I need this. But I kept it.
    (setq plstore-cache-passphrase-for-symmetric-encryption t)
    ;; Same thing here. This is more or less
    ;; lazy copy pasting without reading the descriptions
    (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

    (use-package org-gcal
       ;; This is just to make sure I use the correct version.
       ;; Most likely not needed.
      :elpaca '(org-gcal :host github :repo "kidd/org-gcal.el")
      :init
      (setq org-gcal-client-id "CLIENT_ID_HERE"
            org-gcal-client-secret "CLIENT_SECRET_HERE")
            ...
     )

I think restarting emacs is also necessary. Like restart it twice for safe measure.

After that it will prompt you for a password, after doing the browser stuff for the first time. If you don't enter a password it won't work. If you enter a password you are good to go.

@tiktaaliki
Copy link

hallelujah! @aliyss thank you so much for writing all that out. it worked!!

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

5 participants