Hi, julien and all. I want to use your oauth2 package for my package. It is API wrapper library and it is designed to use from more other packages. oauth2.el <- google-calendar-api.el <- org-gcal.el \_ calfw-gcal.el \_ mhc-gcal.el \_ ... (This ascii art indicates (`org-gcal`, `calfw-gcal`, `mhc-gcal` and more) are depends on `google-calendar-api` and it depends on `oauth2`.) Now, plstore entry id is computed by below sexp, users cannot store two or more token for same `oath-url`, `token-url`, `scope`. > (defun oauth2-compute-id (auth-url token-url scope) > "Compute an unique id based on URLs. > This allows to store the token in an unique way." > (secure-hash 'md5 (concat auth-url token-url scope))) My patch will add the ability to search and save by id if one is given. This will allow multiple independent packages of the same API to store tokens properly. (I thought about adding cliend-id to calculate the id, but rejected it because it is not desirable to change the already stored id. However, if you think it's a good idea, I'm fine with it.) below diff is rejected by me, but you can commit if you fine. ``` From 53bb4d1a55affcdff073febe29b90d19f3603525 Mon Sep 17 00:00:00 2001 From: Naoya Yamashita Date: Fri, 19 Feb 2021 20:25:36 +0900 Subject: [PATCH] * packages/oauth2/oauth2.el: Use client-id and secret to compute id (oauth2-compute-id): Add client-id client-secret as new argument to compute plstore unique id. (oauth2-auth-and-store): Fix the function usage. --- oauth2.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oauth2.el b/oauth2.el index 0099e06217..519ff46d17 100644 --- a/oauth2.el +++ b/oauth2.el @@ -158,17 +158,17 @@ TOKEN should be obtained with `oauth2-request-access'." :group 'oauth2 :type 'file) -(defun oauth2-compute-id (auth-url token-url scope) +(defun oauth2-compute-id (auth-url token-url scope &optional client-id client-secret) "Compute an unique id based on URLs. This allows to store the token in an unique way." - (secure-hash 'md5 (concat auth-url token-url scope))) + (secure-hash 'md5 (concat auth-url token-url scope client-id client-secret))) ;;;###autoload (defun oauth2-auth-and-store (auth-url token-url scope client-id client-secret &optional redirect-uri state) "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)) - (id (oauth2-compute-id auth-url token-url scope)) + (id (oauth2-compute-id auth-url token-url scope client-id client-secret)) (plist (cdr (plstore-get plstore id)))) ;; Check if we found something matching this access (if plist -- 2.30.0 ```