Subject: 30.1; xoauth2 authentication fails in gnus imap mail fetching

From: Anush V <[email-masked]>
Date: Sun, 04 May 2025 09:51:10 -0400

Hello Emacs Maintainers,

I’m using gnus and I’m unable to downloads emails using xoauth2
authentication (provided by auth-source-xoauth2-plugin).  I’m able to
send emails though.

Configuration:
;; emacs --no-init
     (setopt imap-log t)
     (require 'mail-source)
     (add-to-list 'mail-sources '(imap :server "imap.gmail.com"
                                       :port 993
                                       :user "<my_email>"
                                       :stream ssl
                                       ;; dont delete from server
                                       :dontexpunge t
                                       ;; mark as seen after fetching
                                       :fetchflag "\\Seen"
                                       :authentication xoauth2
                                       ))
     (setq gnus-select-method '(nnnil ""))
     (setq gnus-secondary-select-methods
           '((nnmaildir "mail"
                        (directory "~/tmp")
                        (get-new-mail t))))

corresponding logs

     Waiting for response from imap.gmail.com...done
     Mail source (imap :server imap.gmail.com :port 993 :user <my_email> :stream ssl :dontexpunge t :fetchflag \Seen :authentication xoauth2) error (IMAP error: nil)
     nnmaildir: Reading incoming mail (no new mail)...done

I suspect the imap-authenticate call in mail-source-fetch-imap is
failing because xoauth2 and its related CHECK/AUTHENTICATE functions
are missing from imap-authenticator-alist

Please let me know if i’m wrong/missing something.

Since auth-source-xoauth2-plugin is an elpa package, i mailed here and
cc’ed the package maintainer.  If this is wrong place for this, please
let me know the appropriate mailing list.

Thank you for your time

* * *

In GNU Emacs 30.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43,
cairo version 1.18.2)
System Description: Guix System

Configured using:
 'configure
 CONFIG_SHELL=/gnu/store/m0xdsa8cfq6mq1kxgxmpmpg71la4f0b9-bash-minimal-5.1.16/bin/bash
 SHELL=/gnu/store/m0xdsa8cfq6mq1kxgxmpmpg71la4f0b9-bash-minimal-5.1.16/bin/bash --prefix=/gnu/store/lq0nwm8qkj9cmyjm85z3dcqrjnglhcym-emacs-next-pgtk-30.1-rc1-2.7144e84 --enable-fast-install --with-pgtk --with-cairo --with-modules --with-native-compilation=aot --disable-build-details'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
JPEG LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS
TIFF TOOLKIT_SCROLL_BARS TREE_SITTER XIM GTK3 ZLIB

--
Regards,
Anush V