From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Cesar Crusius Newsgroups: gmane.emacs.devel Subject: Re: Any interest in an XOAUTH2 patch for smtpmail (Gmail 2-factor auth)? Date: Sat, 06 Jan 2018 22:19:08 -0800 Message-ID: <87wp0u2ntv.fsf@gmail.com> References: <87373j4tcf.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1515305969 3891 195.159.176.226 (7 Jan 2018 06:19:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 7 Jan 2018 06:19:29 +0000 (UTC) User-Agent: mu4e 0.9.18; emacs 25.3.1 Cc: emacs-devel@gnu.org To: John Wiegley Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 07 07:19:25 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eY4Ik-0000Xm-HF for ged-emacs-devel@m.gmane.org; Sun, 07 Jan 2018 07:19:22 +0100 Original-Received: from localhost ([::1]:39820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eY4Ki-0005dx-Mz for ged-emacs-devel@m.gmane.org; Sun, 07 Jan 2018 01:21:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eY4Ka-0005dh-EL for emacs-devel@gnu.org; Sun, 07 Jan 2018 01:21:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eY4KW-0004HC-EW for emacs-devel@gnu.org; Sun, 07 Jan 2018 01:21:16 -0500 Original-Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:32848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eY4KW-0004Fx-8E; Sun, 07 Jan 2018 01:21:12 -0500 Original-Received: by mail-pl0-x243.google.com with SMTP id 1so5698534plv.0; Sat, 06 Jan 2018 22:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=PjUtwPML4C6rewnWqwDd5wIpT2xfa1xrXBCvI46y0Y8=; b=vEOomFfvw2I1nPrM24Mh+nGUIJr9P7d48V008Qhd9Duh0gj8/9ZrM85HaHTu7xCRHu AQpivNfm2hwYyfWKaC6PXB8zo93h/JH2vUYxveEJw6989gH7wh76dH3GmiVqlExa01lY 0BYecwAEusgdCAph/n2Y+0UAn34cD3yl4KlINAmfCn9rZVSjJ3MSEsPsUGciB6AJl5HZ Od9GB7pkuyUo7Xo96Pjgkuq5CTkb9ueIt1h6vIprvRSyUpl/HEqJ/35FyAr2scbPztDv MmL38J6sCln2vBIxlc+9+CL56yFPFfOj7ZKqwa7Oy/zVFPL9QxUrdad0lhVQxPYi4Eyr +p3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=PjUtwPML4C6rewnWqwDd5wIpT2xfa1xrXBCvI46y0Y8=; b=SaFPqcH36Xh4P4gU06WvqC1js4m2T7q/U+lPuXgTJfR5jUm21/ElDYYxPpOJn8a6Rn sFEHzvRrMWPomYpuE3JXpZHVi+AVrr0kxl1OZnWDeSBSF/xjFaC4C07NezJYFKMTg9/F bvdlzle6gUwxjP0DuYC5vMLQDgrCSuujV1AlXuAV19hVHH86t97kAOyEWbTdc7MEUyX5 hdBoOVTjG/CUoFZ3C9p3KtkAYj8ze5QBz0qQBLIMVcymuEIzcgAFTtsIx68FJSLA5bqw kOW7RsFz5lIl2BVCAlwBPgs1uLktWb40LlzjXx4uHXPCNyRHvRpN0JVB2e34TpigsiMC d9eg== X-Gm-Message-State: AKGB3mIpIDNuUXyg4eR2FrIyQF2X6ZSt8r1nKdH6Dgaah9r6Qzy3n+XO m8VI91exAAcE+DenW0vRFXyOxOxJ X-Google-Smtp-Source: ACJfBotk/FrWlXyaDLCwewxonQxMdoIiEs7qa/7WQ3J7EFVV53IwIEEMmu4ROSQxBNRyfsTVFmzn5Q== X-Received: by 10.84.233.207 with SMTP id m15mr8247795pln.155.1515306070270; Sat, 06 Jan 2018 22:21:10 -0800 (PST) Original-Received: from cesars-w520 (c-24-4-33-27.hsd1.ca.comcast.net. [24.4.33.27]) by smtp.gmail.com with ESMTPSA id s81sm21126599pfg.60.2018.01.06.22.21.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 06 Jan 2018 22:21:09 -0800 (PST) In-reply-to: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221653 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat 06 Jan 2018 at 05:32, John Wiegley wrote: >>>>>> "CC" =3D=3D Cesar Crusius writes: > > CC> I recently had to add XOAUTH2 support in smtpmail to access my two-fa= ctor > CC> authenticated Gmail account, which turned out to be surprisingly simp= le > CC> (my hack has about 20 lines of code, I guess it would about double to= do > CC> it properly). > > CC> It uses oauth2.el, so my plan would be to make smtpmail load that lib= rary > CC> on demand, in case the new smtpmail-xoauth2 variables are configured.= I > CC> guess the required functionality could be copy-and-pasted, but that s= eems > CC> a waste. > > CC> Is there any interest in a patch? > > This sounds useful to me. How will users know to enable the extra behavio= r? Now that I made the hack "proper," I think I may take another route here. SMTP XOAuth2, basically a Gmail-only thing, probably does not belong in the Emacs main repository. Instead, 1. All that needs to happen in smtpmail.el is for the 'smtpmail-try-auth-methods' to have the following patch: diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 20cbeb5f4e..a33a552cd0 100644 =2D-- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -547,6 +551,13 @@ The list is in preference order.") (not password)) ;; No mechanism, or no credentials. mech) + ((eq mech 'xoauth2) + (smtpmail-command-or-throw + process + (concat "AUTH XOAUTH2 " + (base64-encode-string + (concat "user=3D" user "\1auth=3DBearer " password "\1\1") t)) + 235)) ((eq mech 'cram-md5) (setq ret (smtpmail-command-or-throw process "AUTH CRAM-MD5")) (when (eq (car ret) 334) 2. I can create a MELPA package 'auth-source-xoauth2.el' that can then be transparently used to provide the XOAuth2 "password" when required. smtpmail.el should /not/ include xoauth2 in the supported auth methods by default, as the configuration is non-trivial, and it would likely immediately break all Gmail configurations using application passwords. =2D-=20 Cesar Crusius --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAEBCAAdFiEEsu/ErKn7yEV7E0FU/X9qSDfQj2EFAlpRu9wACgkQ/X9qSDfQ j2F7oAv/eVEj2HsS7J8PVvRxIOXEqIBND2OboGOJio1h10rpRTRZvQsOO4IdY0K2 ZVPEGtf35owrVDGG2r/ZXEhQhgEzpinexNW4xWy4zopUxXZNK9m5i7K3ad6Xi8Vu a8K8eYtT2Z0cBfJSyqCHAG1I8GL2tvUYRvA8CnGanqjnU3Lwx6kxsYXlkydHLh0p m6kvsaR8gkjqprr5i5vh2yRH3NB5qCjACCSQeT2mxdi5BLqjWM8ejqUv03sZpvWC KxWOnxevnRU0i/8SpLLWGT1ZtKxAXkoSwkNsLq+224R9qLxHROKBrbHc9jCEQFSh 9Sxak/TN0ybbTDSatM1MSkBhZjRagpNNLFr9MppyRbkYmypCkgO2LqFBzt8Hk38Y syqHCeGiNBATG2YKhWhzqQjWKPYhrwfh3M3R5EFH/T94ADu+jJAddWVEq0usmL+b Q0n0SL5bPx00Nzv33QY/i99XBWpu0fQEPIIk4eOmfZjYy3aYQ85Mu8TEQQAbN3yI mi70EFdS =W9BX -----END PGP SIGNATURE----- --=-=-=--