3a99537a1ffdf16005307a7250382df60434d248 — Thomas Fitzsimmons 9 months ago a60ed14
Add autoloads and configuration validation

* url-http-oauth.el: Update commentary.
(url-http-oauth-uninterpose, url-http-oauth-interposed-p):
(url-http-oauth-interpose): Use let, not let*.  Validate
client-identifier field.
1 files changed, 10 insertions(+), 4 deletions(-)

M url-http-oauth.el
M url-http-oauth.el => url-http-oauth.el +10 -4
@@ 21,11 21,11 @@

;;; Commentary:
;; This package adds OAuth 2.0 support to Emacs's URL library.
;; url-http-oauth adds OAuth 2.0 support to Emacs's URL library.
;; Installation:
;; M-x package-install RET url-http-oauth RET
;; M-x package-install RET url-http-oauth
;; Usage:

@@ 99,6 99,7 @@ URL is an object or a string."
;; catches on, authorization-url and access-token-url can be made
;; optional and their values retrieved automatically.  As of early
;; 2023, RFC 8414 is not consistently implemented yet.
(defun url-http-oauth-interpose (url-settings)
  "Arrange for Emacs to use OAuth 2.0 to access a URL using URL-SETTINGS.
URL-SETTINGS is an association list (alist) with fields whose

@@ 139,14 140,18 @@ REDIRECT_URI.
AUTHORIZATION-CODE-FUNCTION is an elisp function that takes an
authorization URL as a string argument, and returns, as a string,
a full URL containing a code value in its query string."
  (let* ((client-secret-method
          (cdr (assoc "client-secret-method" url-settings))))
  (let ((client-identifier (cdr (assoc "client-identifier" url-settings)))
         (cdr (assoc "client-secret-method" url-settings))))
    (unless (and (stringp client-identifier) (> (length client-identifier) 0))
      (error "url-http-oauth: Unset client-identifier value"))
    (unless (or (eq client-secret-method 'prompt) (eq client-secret-method nil))
      (error "url-http-oauth: Unrecognized client-secret-method value"))
        (add-to-list 'url-http-oauth--interposed url-settings)

(defun url-http-oauth-uninterpose (url-settings)
  "Arrange for Emacs not to use OAuth 2.0 when accessing URL in URL-SETTINGS.
This function does the opposite of `url-http-oauth-interpose'."

@@ 155,6 160,7 @@ This function does the opposite of `url-http-oauth-interpose'."
            (delete url-settings url-http-oauth--interposed))

(defun url-http-oauth-interposed-p (url)
  "Return non-nil if `url' will use OAuth 2.0 to access URL.
URL is an object."