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?
My approach: https://gileschamberlin.wordpress.com/2023/06/13/using-gnus-with-a-local-email-server/
The gmail portion of that is from when app specific passwords still worked, but Oauth is covered in the Office365 section.