GNU bug report logs - #79168
30.1; Proposed changes for oauth2

Previous Next

Package: emacs;

Reported by: Xiyue Deng <manphiz <at> gmail.com>

Date: Mon, 4 Aug 2025 00:00:01 UTC

Severity: normal

Found in version 30.1

Done: Sean Whitton <spwhitton <at> spwhitton.name>

Full log


Message #68 received at 79168 <at> debbugs.gnu.org (full text, mbox):

From: Xiyue Deng <manphiz <at> gmail.com>
To: 79168 <at> debbugs.gnu.org
Cc: Xiyue Deng <manphiz <at> gmail.com>
Subject: [PATCH 07/11] Drop unused code
Date: Fri,  8 Aug 2025 23:45:46 -0700
* packages/oauth2/oauth2.el: Drop functions
oauth2-url-append-access-token, oauth2-authz-bearer-header,
oauth2-extra-headers, oauth2--url-http-handle-authentication-hack,
oauth2-url-retrieve-synchronously, oauth2-url-retrieve.  These
functions are not used by other functions and not required for getting
or refreshing token info.
* packages/oauth2/oauth2.el: Drop requirement of `(nadvice "0.3")'; no
longer using advice.
---
 oauth2.el | 72 +------------------------------------------------------
 1 file changed, 1 insertion(+), 71 deletions(-)

diff --git a/oauth2.el b/oauth2.el
index 4541893346..6f7b6a27db 100644
--- a/oauth2.el
+++ b/oauth2.el
@@ -5,7 +5,7 @@
 ;; Author: Julien Danjou <julien <at> danjou.info>
 ;; Version: 0.17
 ;; Keywords: comm
-;; Package-Requires: ((cl-lib "0.5") (nadvice "0.3"))
+;; Package-Requires: ((cl-lib "0.5"))
 
 ;; This file is part of GNU Emacs.
 
@@ -248,76 +248,6 @@ Returns an `oauth2-token'."
         (plstore-save plstore)
         token))))
 
-(defun oauth2-url-append-access-token (token url)
-  "Append access token to URL."
-  (concat url
-          (if (string-match-p "\?" url) "&" "?")
-          "access_token=" (oauth2-token-access-token token)))
-
-(defun oauth2-authz-bearer-header (token)
-  "Return `Authoriztions: Bearer' header with TOKEN."
-  (cons "Authorization" (format "Bearer %s" token)))
-
-(defun oauth2-extra-headers (extra-headers)
-  "Return EXTRA-HEADERS with `Authorization: Bearer' added."
-  (cons (oauth2-authz-bearer-header
-         (oauth2-token-access-token (car oauth2--token-data)))
-        extra-headers))
-
-
-;; FIXME: We should change URL so that this can be done without an advice.
-(defun oauth2--url-http-handle-authentication-hack (orig-fun &rest args)
-  (if (not oauth2--url-advice)
-      (apply orig-fun args)
-    (let ((url-request-method url-http-method)
-          (url-request-data url-http-data)
-          (url-request-extra-headers
-           (oauth2-extra-headers url-http-extra-headers)))
-      (oauth2-refresh-access (car oauth2--token-data))
-      (url-retrieve-internal (cdr oauth2--token-data)
-                             url-callback-function
-                             url-callback-arguments)
-      ;; This is to make `url' think it's done.
-      (when (boundp 'success) (setq success t)) ;For URL library in Emacs<24.4.
-      t)))                                      ;For URL library in Emacs≄24.4.
-(advice-add 'url-http-handle-authentication :around
-            #'oauth2--url-http-handle-authentication-hack)
-
-;;;###autoload
-(defun oauth2-url-retrieve-synchronously (token url &optional request-method
-                                                request-data
-                                                request-extra-headers)
-  "Retrieve an URL synchronously using TOKEN to access it.
-TOKEN can be obtained with `oauth2-auth'.  REQUEST-METHOD, REQUEST-DATA,
-and REQUEST-EXTRA-HEADERS are used when retrieving URL.  See also
-`url-retrieve-synchronously'."
-  (let* ((oauth2--token-data (cons token url)))
-    (let ((oauth2--url-advice t)         ;Activate our advice.
-          (url-request-method request-method)
-          (url-request-data request-data)
-          (url-request-extra-headers
-           (oauth2-extra-headers request-extra-headers)))
-      (url-retrieve-synchronously url))))
-
-;;;###autoload
-(defun oauth2-url-retrieve (token url callback
-                                  &optional cbargs request-method request-data
-                                  request-extra-headers)
-  "Retrieve an URL asynchronously using TOKEN to access it.
-TOKEN can be obtained with `oauth2-auth'.  CALLBACK gets called with
-CBARGS when finished. TOKEN can be obtained with `oauth2-auth'.
-REQUEST-METHOD, REQUEST-DATA, and REQUEST-EXTRA-HEADERS are used when
-retrieving URL.  See also `url-retrieve'."
-  ;; TODO add support for SILENT and INHIBIT-COOKIES.  How to handle this in
-  ;; `url-http-handle-authentication'.
-  (let* ((oauth2--token-data (cons token url)))
-    (let ((oauth2--url-advice t)         ;Activate our advice.
-          (url-request-method request-method)
-          (url-request-data request-data)
-          (url-request-extra-headers
-           (oauth2-extra-headers request-extra-headers)))
-      (url-retrieve url callback cbargs))))
-
 (provide 'oauth2)
 
 ;;; oauth2.el ends here
-- 
2.39.5





This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.