this post was submitted on 19 Oct 2023
1 points (100.0% liked)

Emacs

314 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I had a very great setup using app-specific password till now. But now want to move to oauth2 because app-specific passwords will not work any more. So I changed my settings as follows,

;; older setting
;; ...
     (nnimap "gmail"
             (nnimap-address "imap.gmail.com")
             (nnimap-inbox "INBOX")
             (nnimap-expunge immediately)
             (nnimap-stream ssl))
;; ...

I looked for a solution, or rather asked ChatGPT about the oauth2.el thing. And it suggested the following,

;; new settings
;; ...
     (nnimap "gml"
             (nnimap-address "imap.gmail.com")
             (nnimap-inbox "INBOX")
             (nnimap-expunge immediately)
             (nnimap-stream ssl)
             (nnimap-authenticator oauth2)
             (nnimap-oauth2-client-id "client-id")
             (nnimap-oauth2-client-secret "client-secret")
             (nnimap-oauth2-credentials "~/.emacs.d/.gmail.oauth2-token"))
;; ...

I created a new project in Google Cloud Console, enabled Gmail API and generated client-id and client-secret for the above. But this doesn't seem to be working. When I launch Gnus (M-x gnus), it is stuck at "Openning connection to imap.gmail.com via tls...". Default browser is not launched for the oauth2 workflow.

I have tested the following code. It launches the default browser and works just fine,

(require 'oauth2)
(defvar my-oauth2-token 
  (oauth2-auth-and-store "https://accounts.google.com/o/oauth2/auth"
                         "https://accounts.google.com/o/oauth2/token"
                         "https://www.googleapis.com/auth/userinfo.email"
                         "client-id"
			 "client-secret"))

Has anyone here done this kind of configuration - gnus+gmail+oauth2?

you are viewing a single comment's thread
view the rest of the comments
[–] FrostyX_cz@alien.top 1 points 1 year ago

Hello, I don't use Gnus but mbsync+gmail+oauth2. Took me a long time to setup, so I wrote a blog post with the instructions.

https://frostyx.cz/posts/synchronize-your-2fa-gmail-with-mbsync

I think you will be able to cherry-pick the configuration pieces that you need from it.