diff options
author | Roland Winkler <winkler@gnu.org> | 2021-08-05 12:33:21 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-08-05 12:33:21 +0200 |
commit | 1505dca91f2ef8de3ea20fb2177539700ac1f2fc (patch) | |
tree | c928df825187de4e0b0047f7fe2c2dc752a14998 /lisp | |
parent | 50d3178a4fa6fbfaaaeee7025e8d9ad3a070aea0 (diff) | |
download | emacs-1505dca91f2ef8de3ea20fb2177539700ac1f2fc.tar.gz emacs-1505dca91f2ef8de3ea20fb2177539700ac1f2fc.tar.bz2 emacs-1505dca91f2ef8de3ea20fb2177539700ac1f2fc.zip |
Add support for the oauth2.el library in nnimap and smtpmail
* doc/misc/gnus.texi (Customizing the IMAP Connection):
* doc/misc/smtpmail.texi (Authentication): Mention it.
* lisp/gnus/nnimap.el (nnimap-login): Support oauth2.
* lisp/mail/smtpmail.el (smtpmail-try-auth-method): New function
for oauth2.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/gnus/nnimap.el | 7 | ||||
-rw-r--r-- | lisp/mail/smtpmail.el | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 3e2a202a6cf..3cf65453f3b 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -599,6 +599,13 @@ during splitting, which may be slow." (eq nnimap-authenticator 'anonymous) (eq nnimap-authenticator 'login))) (nnimap-command "LOGIN %S %S" user password)) + ((and (nnimap-capability "AUTH=XOAUTH2") + (eq nnimap-authenticator 'xoauth2)) + (nnimap-command "AUTHENTICATE XOAUTH2 %s" + (base64-encode-string + (format "user=%s\001auth=Bearer %s\001\001" + (nnimap-quote-specials user) + (nnimap-quote-specials password))))) ((and (nnimap-capability "AUTH=CRAM-MD5") (or (null nnimap-authenticator) (eq nnimap-authenticator 'cram-md5))) diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 33bdd050bdc..8e3927cdcf2 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -636,6 +636,14 @@ USER and PASSWORD should be non-nil." (base64-encode-string (concat "\0" user "\0" password) t)) 235)) +(cl-defmethod smtpmail-try-auth-method + (process (_mech (eql xoauth2)) user password) + (smtpmail-command-or-throw + process + (concat "AUTH XOAUTH2 " + (base64-encode-string + (concat "user=" user "\1auth=Bearer " password "\1\1") t)))) + (defun smtpmail-response-code (string) (when string (with-temp-buffer |