[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/oauth2 54da2ff 21/23: * packages/oauth2/oauth2.el: Use
From: |
Stefan Monnier |
Subject: |
[elpa] externals/oauth2 54da2ff 21/23: * packages/oauth2/oauth2.el: Use lexical-binding, cl-lib, and nadvice |
Date: |
Tue, 1 Dec 2020 16:32:01 -0500 (EST) |
branch: externals/oauth2
commit 54da2ffbaa2b42ebc111695263b7cd323cabf05b
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* packages/oauth2/oauth2.el: Use lexical-binding, cl-lib, and nadvice
(oauth2-token-file): Remove :group arg for non-existing group.
(oauth2--url-http-handle-authentication-hack): New function
extracted from the previous defadvice.
(url-http-handle-authentication): Use it.
---
oauth2.el | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/oauth2.el b/oauth2.el
index 532bc13..0055d42 100644
--- a/oauth2.el
+++ b/oauth2.el
@@ -1,10 +1,11 @@
-;;; oauth2.el --- OAuth 2.0 Authorization Protocol
+;;; oauth2.el --- OAuth 2.0 Authorization Protocol -*- lexical-binding:t -*-
;; Copyright (C) 2011-2020 Free Software Foundation, Inc
;; Author: Julien Danjou <julien@danjou.info>
;; Version: 0.14
;; Keywords: comm
+;; Package-Requires: ((cl-lib "0.5") (nadvice "0.3"))
;; This file is part of GNU Emacs.
@@ -35,11 +36,17 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'plstore)
(require 'json)
(require 'url-http)
+(defvar url-http-data)
+(defvar url-http-method)
+(defvar url-http-extra-headers)
+(defvar url-callback-arguments)
+(defvar url-callback-function)
+
(defun oauth2-request-authorization (auth-url client-id &optional scope state
redirect-uri)
"Request OAuth authorization at AUTH-URL by launching `browse-url'.
CLIENT-ID is the client id provided by the provider.
@@ -70,7 +77,7 @@ It returns the code provided by the service."
(kill-buffer (current-buffer))
data))))
-(defstruct oauth2-token
+(cl-defstruct oauth2-token
plstore
plstore-id
client-id
@@ -142,7 +149,8 @@ TOKEN should be obtained with `oauth2-request-access'."
(defcustom oauth2-token-file (concat user-emacs-directory "oauth2.plstore")
"File path where store OAuth tokens."
- :group 'oauth2
+ ;; FIXME: This var doesn't belong to any group. Either add it to some
+ ;; pre-existing group or create an `oauth2' group for it.
:type 'file)
(defun oauth2-compute-id (auth-url token-url scope)
@@ -202,20 +210,22 @@ This allows to store the token in an unique way."
;; FIXME: We should change URL so that this can be done without an advice.
-(defadvice url-http-handle-authentication (around oauth-hack activate)
+(defun oauth2--url-http-handle-authentication-hack (orig-fun &rest args)
(if (not oauth--url-advice)
- ad-do-it
+ (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 oauth--token-data))
- (url-retrieve-internal (cdr oauth--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.
- (setq ad-return-value t))) ;For URL library in Emacs≥24.4.
+ (oauth2-extra-headers url-http-extra-headers)))
+ (oauth2-refresh-access (car oauth--token-data))
+ (url-retrieve-internal (cdr oauth--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)
- [elpa] externals/oauth2 a51dda4 04/23: * oauth2.el: Require json., (continued)
- [elpa] externals/oauth2 a51dda4 04/23: * oauth2.el: Require json., Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 6824409 09/23: * packages/oauth2/oauth2.el: Revert fix URL double escaping, update to 0.5, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 d5e5e70 10/23: oauth2: add redirect-uri parameter, update to 0.6, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 1d352b3 17/23: Fix some quoting problems in doc strings, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 86a4afd 19/23: fix(oauth2): rename forgotten instance of resource-url -> scope, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 7619d08 23/23: * .gitignore: New file, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 61bcabe 16/23: oauth2: send authentication token via Authorization header, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 bf96d9f 11/23: oauth2: store access-reponse, bump versino to 0.7, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 bcf36ae 18/23: feat(oauth2): add state parameter support, rename resource-url to scope, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 0abcea1 15/23: oauth2.el: Add support for async retrieve., Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 54da2ff 21/23: * packages/oauth2/oauth2.el: Use lexical-binding, cl-lib, and nadvice,
Stefan Monnier <=
- [elpa] externals/oauth2 b383a42 22/23: * packages/oauth2/oauth2.el: update version to 0.15, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 8f5cf79 14/23: * oauth2.el: Only require CL at compile time and avoid flet., Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 9108df0 20/23: feat(oauth2): do not include &client_secret if no client_secret set, Stefan Monnier, 2020/12/01