Subject: Re: bug#78366: 30.1; auth-source-xoauth2-plugin conflicts with multiple Google accounts

From: Robert Pluim <[email-masked]>
Date: Wed, 14 May 2025 14:50:21 +0200

>>>>> On Tue, 13 May 2025 09:55:24 -0700, Xiyue Deng <[email-masked]> said:
    >> 
    >> 
    >> I did some debugging.  According to comment “;; A string result is an
    >> error.” in the function smtpmail-try-auth-methods, the function call
    >> (smtpmail-try-auth-method process 'xoauth2 "user" "password") should
    >> return a string when authentication fails.  However, it currently
    >> returns a list instead, which prevents other authentication methods
    >> from being tried.
    >> 
    >> [...]

    Xiyue> Thanks for the investigation! If the try-method don't fallback to the
    Xiyue> other supported auth methods then it will break.  I tried to read the
    Xiyue> code of `smtpmail-try-auth-method' for xoauth2[1], and besides lacking
    Xiyue> encoding user and password into utf-8, I don't see anything obviously
    Xiyue> different from plain[2] and not sure why it would return a list.

utf-8 encoding is not necessary for xoauth2, see commit
745847ba8eca27e981a50ad91b628bbce35bb0f3

    Xiyue> Would be great if any Emacs developer can shed some light here.

`smtpmail-try-auth-method' will call `smtpmail-command-or-throw
process', which will return a list upon success, and string upon
failure. That decision is made by `smtpmail-ok-p', so thatʼs the
function you should check. Setting `smtpmail-debug-info' to t will get
you a trace buffer of the SMTP commands, that should help.

Robert
--