From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Xiyue Deng Newsgroups: gmane.emacs.bugs Subject: bug#72992: 29.4; towards xoauth2 support in Emacs Date: Sun, 22 Sep 2024 14:44:33 -0700 Message-ID: <87jzf34b3y.fsf@debian-hx90.lan> References: <87h6ayfo87.fsf_-_@debian-hx90.lan> <877cb8oihg.fsf@debian-hx90.lan> <878qvocjkz.fsf@ust.hk> <87ldzom4rz.fsf@debian-hx90.lan> <87zfo4au81.fsf@ust.hk> <66f00712.170a0220.29d948.0047SMTPIN_ADDED_BROKEN@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27548"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.38.3 (https://notmuchmail.org) Emacs/29.4 (x86_64-pc-linux-gnu) Cc: Ted Zlatanov , 72992@debbugs.gnu.org, Philip Kaludercic , Stefan Kangas To: =?UTF-8?Q?Bj=C3=B6rn?= Bidar , Andrew Cohen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 22 23:46:49 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ssUPp-0006yu-8r for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Sep 2024 23:46:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ssUPh-0004xo-OX; Sun, 22 Sep 2024 17:46:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ssUPg-0004wy-Oa for bug-gnu-emacs@gnu.org; Sun, 22 Sep 2024 17:46:40 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ssUPg-0007ET-Eb for bug-gnu-emacs@gnu.org; Sun, 22 Sep 2024 17:46:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=nRVJqS24q0UyBrS3WOkCMeeTu6fof5dqg61rPUgQXjk=; b=LPeMOmVWPN3lWbby9nDtitRZUCp+dK+WUu3CsFdbF/SJkg0wr7MG3386BcxrmAwX98x7N1pnY8yU8SEdI0NJ4Gw6WQkv9IpSfwYOGQ34dDQg7CJ6FQHrQw1rA3zzjkpATwwIMeyOpN7ys1aaCRX6mnNheNWGaXlcgQdE9C9KXctGe+BpcDbnAj2py23Grjk1yF2cN+WgbZcPibQAJF1/oIifbV9hs6sfP8YqOpBfL/QDlucrGknEUxebbMElo/QKHQCBXQmzWj/BwhEJX+WTr2GH+BmVQgYYquytHegXFN37bRPn9ZeAWemrYeHgUFoL1QHHxds0CXVPz0ykLBfjWg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ssUQ2-0004Vx-52 for bug-gnu-emacs@gnu.org; Sun, 22 Sep 2024 17:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Xiyue Deng Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Sep 2024 21:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72992 X-GNU-PR-Package: emacs Original-Received: via spool by 72992-submit@debbugs.gnu.org id=B72992.172704156617277 (code B ref 72992); Sun, 22 Sep 2024 21:47:02 +0000 Original-Received: (at 72992) by debbugs.gnu.org; 22 Sep 2024 21:46:06 +0000 Original-Received: from localhost ([127.0.0.1]:42864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssUP8-0004Ub-9C for submit@debbugs.gnu.org; Sun, 22 Sep 2024 17:46:06 -0400 Original-Received: from mail-pg1-f169.google.com ([209.85.215.169]:54557) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssUP6-0004U1-G0 for 72992@debbugs.gnu.org; Sun, 22 Sep 2024 17:46:05 -0400 Original-Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7163489149eso3008951a12.1 for <72992@debbugs.gnu.org>; Sun, 22 Sep 2024 14:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727041475; x=1727646275; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nRVJqS24q0UyBrS3WOkCMeeTu6fof5dqg61rPUgQXjk=; b=Gn+O9gkZjZrXnL+wHdpR7O/qDP9CTO+7Izfn01CX51TuXL44FRNfsBz6iM2i7fkJB2 rCaR70NDaK8S02/j/DpSpFhyxltT0CI4qEqTeNOk8C6Cp3y8YqTZpy0ZtdiUBQCGiWiY Og0CMsSN6oyqjhTLqsUlRSxZqlAERy3G1RRu2Stlm2q8IZlLtZeTN7by0OoALOeWxJ9B oNEobp0Y0DfR24LwawViQbjNs5Vd2cW1db4mWO3yDxYnJ/ToYVJPokakFdU1VAHbKQnZ b04dF+/hTEqFayMbC7aYTOpGHFMwFraGDJRoPXOXCRgaXfbx+R1IUPCi4WUMp4GljIkM tmHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727041475; x=1727646275; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nRVJqS24q0UyBrS3WOkCMeeTu6fof5dqg61rPUgQXjk=; b=jtXhNvFFvtqW/+CIe769d3MFbQX4tYyEbQQBPGHooIwDefIo4JvpsBxV+S6L75SvBa d3L+JWDKKIyTYyyDlYIZwMxi8AY6pZXP1PRgt2zMYk3ARHMqi/kqAtRDfFM+/769jOF/ D5GNanpsj/5ZtdVKPgb5sMstdw8HQiU9AK408SS3ZpbaPyFvSjaLpVX3lVxk9J5tUGMB aad/cP8sIX427gNjAA1Pek5EAFxgygwK/Ls20/4INr0pDRh6Sg2mezXRq2M2aMUA1cp7 T2Fz4VGWub0Z8/URc7hWX5AUdgrJ8zGHoHnhf45NyPVOSjmtRGYi9GBw5+JNd+JNzewn Q92A== X-Forwarded-Encrypted: i=1; AJvYcCXnbS7Ru8Dbf4z8o7vwpTkOSwCvFIPCOaL0CICaAAE17BpTEAf08HJHKxHESNLkFKlOpuk9aw==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzzTNAczZTApX94nJG7mIrzSfL1C9g0U4HojKCZCa9+3d+PNCLn kj1I6Q5pOV4iU2TXCBarML7jdqGapvdpGXHTqGpbIJw+e2r1HfhE X-Google-Smtp-Source: AGHT+IHwdzp4MBi9JXqNt0WoQVCrJhGKtM3vLB20HLM5blQeguw+R/6xZDaWhmQuIj0FQb4idhmW6g== X-Received: by 2002:a17:90b:164b:b0:2d3:bc5f:715f with SMTP id 98e67ed59e1d1-2dd7f405e33mr13187872a91.10.1727041475387; Sun, 22 Sep 2024 14:44:35 -0700 (PDT) Original-Received: from debian-hx90 (syn-076-094-249-045.res.spectrum.com. [76.94.249.45]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd7f7bb016sm5883617a91.3.2024.09.22.14.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 14:44:35 -0700 (PDT) In-Reply-To: <66f00712.170a0220.29d948.0047SMTPIN_ADDED_BROKEN@mx.google.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292256 Archived-At: Hi Bj=C3=B6rn, Bj=C3=B6rn Bidar writes: > Andrew Cohen writes: > >>>>>>> "XD" =3D=3D Xiyue Deng writes: >> >> XD> Hi Andrew, Andrew Cohen writes: >> >> >>>>>>> "XD" =3D=3D Xiyue Deng writes: >> >>=20 >> >> [...] >> >> XD> The basic support is actually in the Emacs core already, >> XD> e.g. for Gnus nnimap[2] and smtpmail[3]. However, this assumes >> XD> one to put the access_token in place of `:secret' in the >> XD> auth-source file as Emacs uses password as the access_token in >> XD> both places. However, access_token expires quite frequently >> XD> (e.g. about 1 hour for Gmail) and without refreshing it >> XD> automatically it is practically impossible to use conveniently. >> XD> Hence the propose hack and the following suggestion. >> >>=20 >> >>=20 >> >> This isn't actually true. When I added the support many years >> >> ago, I updated auth-source so that the :secret field can be a >> >> function, and this is how you should be using the current xoauth >> >> support. >> >> XD> Thanks for pointing this out! I found the place where `:secret' >> XD> is handled as a function[1]. However, this requires a user to >> XD> implement the oauth2 logic oneself, which I'm afraid is a bit >> XD> too low-level and error-prone. (Actually, can I actually put a >> XD> lisp function in auth-source.gpg?)=20=20 >> >> I don't think you have to do anything low level, and I don't think there >> is anything error prone here; you can use the functions from oauth >> themselves (oauth2.el can create its own plstores, but I prefer to use >> auth-source.el to manage the stores). The only things needed are a call >> to oauth2-refresh-access to get a new token, and then >> oauth2-token-access-token to return the new access token. > > Is this documented? If yes where? > I tried to look inside the auth manual nothing was mentioned. > Would this method work with all backends? AIUI as of now you would need to implement this logic as a function in `:secret' of the auth-source entry. Please do correct me though. --=20 Xiyue Deng