[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/oauth2 d5e5e70 10/23: oauth2: add redirect-uri paramete
From: |
Stefan Monnier |
Subject: |
[elpa] externals/oauth2 d5e5e70 10/23: oauth2: add redirect-uri parameter, update to 0.6 |
Date: |
Tue, 1 Dec 2020 16:31:59 -0500 (EST) |
branch: externals/oauth2
commit d5e5e7038401a859e4c2f854beeb9502ee0cea24
Author: Julien Danjou <julien@danjou.info>
Commit: Julien Danjou <julien@danjou.info>
oauth2: add redirect-uri parameter, update to 0.6
---
oauth2.el | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/oauth2.el b/oauth2.el
index 3f76a3d..029e154 100644
--- a/oauth2.el
+++ b/oauth2.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2011-2012 Free Software Foundation, Inc
;; Author: Julien Danjou <julien@danjou.info>
-;; Version: 0.5
+;; Version: 0.6
;; Keywords: comm
;; This file is part of GNU Emacs.
@@ -38,14 +38,15 @@
(require 'plstore)
(require 'json)
-(defun oauth2-request-authorization (auth-url client-id &optional scope state)
+(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.
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=urn:ietf:wg:oauth:2.0:oob"
+ "&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: "))
@@ -76,7 +77,7 @@ It returns the code provided by the service."
refresh-token
token-url)
-(defun oauth2-request-access (token-url client-id client-secret code)
+(defun oauth2-request-access (token-url client-id client-secret code &optional
redirect-uri)
"Request OAuth access at TOKEN-URL.
The CODE should be obtained with `oauth2-request-authorization'.
Return an `oauth2-token' structure."
@@ -88,7 +89,8 @@ Return an `oauth2-token' structure."
"client_id=" client-id
"&client_secret=" client-secret
"&code=" code
-
"&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code"))))
+ "&redirect_uri=" (url-hexify-string (or redirect-uri
"urn:ietf:wg:oauth:2.0:oob"))
+ "&grant_type=authorization_code"))))
(make-oauth2-token :client-id client-id
:client-secret client-secret
:access-token (cdr (assoc 'access_token result))
@@ -119,14 +121,15 @@ TOKEN should be obtained with `oauth2-request-access'."
token)
;;;###autoload
-(defun oauth2-auth (auth-url token-url client-id client-secret &optional scope
state)
+(defun oauth2-auth (auth-url token-url client-id client-secret &optional scope
state redirect-uri)
"Authenticate application via OAuth2."
(oauth2-request-access
token-url
client-id
client-secret
(oauth2-request-authorization
- auth-url client-id scope state)))
+ auth-url client-id scope state redirect-uri)
+ redirect-uri))
(defcustom oauth2-token-file (concat user-emacs-directory "oauth2.plstore")
"File path where store OAuth tokens."
@@ -139,7 +142,7 @@ This allows to store the token in an unique way."
(secure-hash 'md5 (concat auth-url token-url resource-url)))
;;;###autoload
-(defun oauth2-auth-and-store (auth-url token-url resource-url client-id
client-secret)
+(defun oauth2-auth-and-store (auth-url token-url resource-url client-id
client-secret &optional redirect-uri)
"Request access to a resource and store it using `plstore'."
;; We store a MD5 sum of all URL
(let* ((plstore (plstore-open oauth2-token-file))
@@ -156,7 +159,7 @@ This allows to store the token in an unique way."
:refresh-token (plist-get plist :refresh-token)
:token-url token-url)
(let ((token (oauth2-auth auth-url token-url
- client-id client-secret resource-url)))
+ client-id client-secret resource-url nil
redirect-uri)))
;; Set the plstore
(setf (oauth2-token-plstore token) plstore)
(setf (oauth2-token-plstore-id token) id)
- [elpa] externals/oauth2 384ae30 03/23: * packages/oauth2/oauth2.el (oauth2-request-authorization): Add missing, (continued)
- [elpa] externals/oauth2 384ae30 03/23: * packages/oauth2/oauth2.el (oauth2-request-authorization): Add missing, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 c1302df 06/23: oauth2: update version 0.2, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 7513425 07/23: * packages/oauth2/oauth2.el: Fix URL double escaping, update to 0.3, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 37cb216 12/23: oauth2: upgrade to 0.8, add missing require on cl, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 f4f8aca 13/23: oauth2: release 0.9, require url-http, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 e807082 02/23: * packages/oauth2/oauth2.el: Reformat to avoid long lines., Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 ba35131 05/23: oauth2: allow to use any HTTP request type, Stefan Monnier, 2020/12/01
- [elpa] externals/oauth2 e94f9f1 08/23: * packages/oauth2/oauth2.el: Don't use aget, update to 0.4, Stefan Monnier, 2020/12/01
- [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 <=
- [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, 2020/12/01
- [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