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 thread.
View all comments
1 point

I had to use Davmail to get it to work. Now I forward everything, so I don’t run Davmail anymore, but it worked well enough while I needed it: https://lambdaland.org/posts/2023-05-03_email_with_outlook/

permalink
report
reply

Emacs

!emacs@communick.news

Create post

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

Get Emacs

  • Windows
  • Mac OS X
  • GNU/Linux and BSD (Just get it from your distribution’s package manager)

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

Community stats

  • 18

    Monthly active users

  • 562

    Posts

  • 2.4K

    Comments