branch: externals/auth-source-xoauth2-plugin commit 149e9e3f7623f39939daf7206d0db859b8f31a62 Author: Xiyue Deng <manp...@gmail.com> Commit: Xiyue Deng <manp...@gmail.com>
Make xoauth2 the last entry in smtpmail-auth-supported If xoauth2 is tried first and the credentials are incorrect, it will return 334 server challenge, which is not considered a failure by smtpmail but it effectively failed the authentication. Putting xoauth2 the last entry works around this. See also https://debbugs.gnu.org/78366. --- auth-source-xoauth2-plugin.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/auth-source-xoauth2-plugin.el b/auth-source-xoauth2-plugin.el index beee9d4c5e..db5e04bf37 100644 --- a/auth-source-xoauth2-plugin.el +++ b/auth-source-xoauth2-plugin.el @@ -99,7 +99,13 @@ expected that `token_url', `client_id', `client_secret', and (defun auth-source-xoauth2-plugin--enable () "Enable auth-source-xoauth2-plugin." (unless (memq 'xoauth2 smtpmail-auth-supported) - (push 'xoauth2 smtpmail-auth-supported) + ;; smtpmail considers smtp request with a return value less than 400 to be + ;; successful, but for Gmail when an xoauth2 request fails it returns 334 + ;; server challenge, and waiting for a subsequent request with the correct + ;; credentials which will never happen. Putting 'xoauth2 as the last entry + ;; in smtpmail-auth-supported so that it is tried last. See also + ;; https://debbugs.gnu.org/78366. + (add-to-list smtpmail-auth-supported 'xoauth2 t) (setq auth-source-xoauth2-plugin--enabled-xoauth2-by-us t)) (advice-add #'auth-source-search-backends :around