emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/url-http-oauth 9d5c820c90 14/24: Fix auth-source lookup


From: Thomas Fitzsimmons
Subject: [elpa] externals/url-http-oauth 9d5c820c90 14/24: Fix auth-source lookups
Date: Mon, 8 May 2023 21:10:46 -0400 (EDT)

branch: externals/url-http-oauth
commit 9d5c820c9025405637a455fc359b4a3fd03c5919
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>

    Fix auth-source lookups
    
    * url-http-oauth.el (url-http-oauth-port): Always return the port
    as a string.
    (url-http-oauth-get-bearer): Use empty string for null user.
---
 url-http-oauth.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/url-http-oauth.el b/url-http-oauth.el
index 6d2f68c5d7..8ec20bc314 100644
--- a/url-http-oauth.el
+++ b/url-http-oauth.el
@@ -102,7 +102,10 @@ This function does the opposite of 
`url-http-oauth-interpose'."
 (defun url-http-oauth-port (url)
   "Return port of URL object.
 Assume an HTTPS URL that does not specify a port uses 443."
-  (or (url-port url) (when (string= "https" (url-type url)) 443)))
+  (let ((port-number (url-port url)))
+    (if port-number
+       (number-to-string port-number)
+      (when (string= "https" (url-type url)) "443"))))
 
 (defun url-http-oauth-get-access-token-grant (url code)
   "Get an access token for URL using CODE."
@@ -202,7 +205,7 @@ URL is a parsed object."
                           (car
                            (let ((auth-source-do-cache nil))
                              (auth-source-search
-                              :user (url-user url)
+                              :user (or (url-user url) "")
                               :host (url-host url)
                               :port (url-http-oauth-port url)
                               :path path
@@ -222,7 +225,7 @@ URL is a parsed object."
                (bearer-retrieved (gethash "access_token" grant))
                (auth-result (let ((auth-source-do-cache nil))
                               (auth-source-search
-                               :user (url-user url)
+                               :user (or (url-user url) "")
                                :host (url-host url)
                                :port (url-http-oauth-port url)
                                :path path
@@ -238,7 +241,7 @@ URL is a parsed object."
                                :create '(path scope expiry)
                                :max 1)))
                (save-function (plist-get (car auth-result) :save-function)))
-            ;; Success; save bearer.
+          ;; Success; save bearer.
           (when (functionp save-function)
             (funcall save-function))
           bearer-retrieved))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]