Subject: [oauth2.el] oauth2-auth-and-store: Add optional argument state

From: Xu Chunyang <[email-masked]>
Date: Thu, 26 Mar 2020 04:28:25 +0800

Hi,

I'm using an API which requires state, but oauth2-auth-and-store
doesn't take one, hence this package, by the way, I changed
resource-url to scope, the former looks like a typo.

diff -u --label /Users/xcy/.emacs.d/elpa-27.0.90/oauth2-0.11/oauth2.el
--label \#\<buffer\ oauth2.el\>
/Users/xcy/.emacs.d/elpa-27.0.90/oauth2-0.11/oauth2.el
/var/folders/7f/s191h4q97p90374yw15ssrs00000gn/T/buffer-content-9fSeJ8
--- /Users/xcy/.emacs.d/elpa-27.0.90/oauth2-0.11/oauth2.el
+++ #<buffer oauth2.el>
@@ -149,7 +149,7 @@
   (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 &optional redirect-uri)
+(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))
@@ -167,7 +167,7 @@
                            :token-url token-url
                            :access-response (plist-get plist :access-response))
       (let ((token (oauth2-auth auth-url token-url
-                                client-id client-secret resource-url
nil redirect-uri)))
+                                client-id client-secret scope state
redirect-uri)))
         ;; Set the plstore
         (setf (oauth2-token-plstore token) plstore)
         (setf (oauth2-token-plstore-id token) id)

Diff finished.  Thu Mar 26 04:23:21 2020