Subject: bug#72358: 29.4; oauth2.el improvements

From: Xiyue Deng <[email-masked]>
Date: Wed, 14 Aug 2024 01:23:19 -0700

Eli Zaretskii <[email-masked]> writes:

>> From: Xiyue Deng <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Tue, 13 Aug 2024 15:03:30 -0700
>> 
>> Hi Eli,
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> >> Cc: [email-masked]
>> >> From: Xiyue Deng <[email-masked]>
>> >> Date: Fri, 02 Aug 2024 01:15:22 -0700
>> >> 
>> >> BTW, is there any dev available to commit the changes once it's in a
>> >> good shape?
>> >
>> > All the 3 co-maintainers are tracking these discussions and install
>> > changes that are ready to be installed.
>> 
>> It's been a few days since the last time I received feedback for
>> improvements regarding my patches.  Is there any other feedbacks/reviews
>> I am expecting from the co-maintainers?  Please also let me know when
>> it's time to ask for merging and requesting a new tagged release.
>
> ?? The last message in this discussion was just yesterday evening, and
> my understanding is that you are still discussing the issues and did
> not reach the final conclusion.  If I'm mistaken, my apologies;

The recent communication was not related to my patches but to check
whether it is possible to support outlook.com OAuth2 login (and the
conclusion was no because refreshing access token was disabled as
confirmed by MS representative during an online chat.)

> please describe your conclusion and post the patch that you-all agree
> would solve the issues, and let's take it from there.

I actually only received comments from Robert and I have updated my
patches according in [1][2] (also attached in EOM).

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72358#20
[2] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72358#44

-- 
Xiyue Deng
>From 2b9e50cb0948e0b4f28883042109994ffa295d3d Mon Sep 17 00:00:00 2001
From: Xiyue Deng <[email-masked]>
Date: Sun, 21 Jul 2024 14:50:56 -0700
Subject: [PATCH 1/6] Show full authentication URL to let user choose how to
 visit it

* packages/oauth2/oauth2.el (oauth2-request-authorization): show full
authentication URL in user prompt.
---
 oauth2.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/oauth2.el b/oauth2.el
index 7da9702004..3a3e50ad2b 100644
--- a/oauth2.el
+++ b/oauth2.el
@@ -57,14 +57,17 @@
   "Request OAuth authorization at AUTH-URL by launching `browse-url'.
 CLIENT-ID is the client id provided by the provider.
 It returns the code provided by the service."
-  (browse-url (concat auth-url
-                      (if (string-match-p "\?" auth-url) "&" "?")
-                      "client_id=" (url-hexify-string client-id)
-                      "&response_type=code"
-                      "&redirect_uri=" (url-hexify-string (or redirect-uri "urn:ietf:wg:oauth:2.0:oob"))
-                      (if scope (concat "&scope=" (url-hexify-string scope)) "")
-                      (if state (concat "&state=" (url-hexify-string state)) "")))
-  (read-string "Enter the code your browser displayed: "))
+  (let ((url (concat auth-url
+                     (if (string-match-p "\?" auth-url) "&" "?")
+                     "client_id=" (url-hexify-string client-id)
+                     "&response_type=code"
+                     "&redirect_uri=" (url-hexify-string (or redirect-uri "urn:ietf:wg:oauth:2.0:oob"))
+                     (if scope (concat "&scope=" (url-hexify-string scope)) "")
+                     (if state (concat "&state=" (url-hexify-string state)) ""))))
+    (browse-url url)
+    (read-string (concat "Follow the instruction on your default browser, or "
+                         "visit:\n" url
+                         "\nEnter the code your browser displayed: "))))
 
 (defun oauth2-request-access-parse ()
   "Parse the result of an OAuth request."
-- 
2.39.2