;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\304\305\306\307\310\311\312\313\312\314& \207" [require plstore json url-http custom-declare-group oauth2 nil "OAuth 2.0 Authorization Protocol." :group comm :link (url-link :tag "Savannah" "http://git.savannah.gnu.org/cgit/emacs/elpa.git/tree/?h=externals/oauth2") (url-link :tag "ELPA" "https://elpa.gnu.org/packages/oauth2.html")] 10) #@226 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. (fn AUTH-URL CLIENT-ID &optional SCOPE STATE REDIRECT-URI) (defalias 'oauth2-request-authorization #[1282 "\301\302\303\304\305#)\266\203\203\306\202\302\307\310!\311\310\206%\312! \2034\313\310 !P\2025\314 \203C\315\310 !P\202D\314\260!\210\316\317!\207" [inhibit-changing-match-data browse-url "?" nil t string-match "&" "client_id=" url-hexify-string "&response_type=code&redirect_uri=" "urn:ietf:wg:oauth:2.0:oob" "&scope=" "" "&state=" read-string "Enter the code your browser displayed: "] 16 (#$ . 478)]) #@39 Parse the result of an OAuth request. (defalias 'oauth2-request-access-parse #[0 "eb\210\300\301\302\303#\205 \304 \207" [search-forward-regexp "^$" nil t json-read] 4 (#$ . 1187)]) #@66 Make an access request to URL using DATA in POST. (fn URL DATA) (defalias 'oauth2-make-access-request #[514 "\303\304r\305!q\210\306 \307p!\210\211\262,\207" [url-request-extra-headers url-request-data url-request-method "POST" (("Content-Type" . "application/x-www-form-urlencoded")) url-retrieve-synchronously oauth2-request-access-parse kill-buffer] 5 (#$ . 1376)]) #@71 compiler-macro for inlining `oauth2-token-p'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-p--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-p (and (memq (type-of cl-x) cl-struct-oauth2-token-tags) t)) nil] 9 (#$ . 1758)]) (put 'oauth2-token-p 'compiler-macro 'oauth2-token-p--cmacro) #@13 (fn CL-X) (defalias 'oauth2-token-p #[257 "\301!>\205 \302\207" [cl-struct-oauth2-token-tags type-of t] 3 (#$ . 2104)]) (byte-code "\300\301\302\303#\304\305\306\301#\207" [function-put oauth2-token-p side-effect-free error-free put oauth2-token cl-deftype-satisfies] 5) #@77 compiler-macro for inlining `oauth2-token-plstore'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-plstore--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-plstore (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 1))) nil] 9 (#$ . 2386)]) (put 'oauth2-token-plstore 'compiler-macro 'oauth2-token-plstore--cmacro) #@65 Access slot "plstore" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-plstore #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 1] 5 (#$ . 2809)]) (byte-code "\300\301\302\303#\300\207" [function-put oauth2-token-plstore side-effect-free t] 4) #@80 compiler-macro for inlining `oauth2-token-plstore-id'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-plstore-id--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-plstore-id (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 2))) nil] 9 (#$ . 3160)]) (put 'oauth2-token-plstore-id 'compiler-macro 'oauth2-token-plstore-id--cmacro) #@68 Access slot "plstore-id" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-plstore-id #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 2] 5 (#$ . 3598)]) (byte-code "\300\301\302\303#\300\207" [function-put oauth2-token-plstore-id side-effect-free t] 4) #@79 compiler-macro for inlining `oauth2-token-client-id'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-client-id--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-client-id (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 3))) nil] 9 (#$ . 3958)]) (put 'oauth2-token-client-id 'compiler-macro 'oauth2-token-client-id--cmacro) #@67 Access slot "client-id" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-client-id #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 3] 5 (#$ . 4391)]) (byte-code "\300\301\302\303#\300\207" [function-put oauth2-token-client-id side-effect-free t] 4) #@83 compiler-macro for inlining `oauth2-token-client-secret'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-client-secret--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-client-secret (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 4))) nil] 9 (#$ . 4748)]) (put 'oauth2-token-client-secret 'compiler-macro 'oauth2-token-client-secret--cmacro) #@71 Access slot "client-secret" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-client-secret #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 4] 5 (#$ . 5201)]) (byte-code "\300\301\302\303#\300\207" [function-put oauth2-token-client-secret side-effect-free t] 4) #@82 compiler-macro for inlining `oauth2-token-access-token'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-access-token--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-access-token (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 5))) nil] 9 (#$ . 5570)]) (put 'oauth2-token-access-token 'compiler-macro 'oauth2-token-access-token--cmacro) #@70 Access slot "access-token" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-access-token #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 5] 5 (#$ . 6018)]) (byte-code "\300\301\302\303#\300\207" [function-put oauth2-token-access-token side-effect-free t] 4) #@83 compiler-macro for inlining `oauth2-token-refresh-token'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-refresh-token--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-refresh-token (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 6))) nil] 9 (#$ . 6384)]) (put 'oauth2-token-refresh-token 'compiler-macro 'oauth2-token-refresh-token--cmacro) #@71 Access slot "refresh-token" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-refresh-token #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 6] 5 (#$ . 6837)]) (byte-code "\300\301\302\303#\300\207" [function-put oauth2-token-refresh-token side-effect-free t] 4) #@79 compiler-macro for inlining `oauth2-token-token-url'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-token-url--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-token-url (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 7))) nil] 9 (#$ . 7206)]) (put 'oauth2-token-token-url 'compiler-macro 'oauth2-token-token-url--cmacro) #@67 Access slot "token-url" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-token-url #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 7] 5 (#$ . 7639)]) (byte-code "\300\301\302\303#\300\207" [function-put oauth2-token-token-url side-effect-free t] 4) #@85 compiler-macro for inlining `oauth2-token-access-response'. (fn CL-WHOLE-ARG CL-X) (defalias 'oauth2-token-access-response--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block oauth2-token-access-response (progn (or (oauth2-token-p cl-x) (signal 'wrong-type-argument (list 'oauth2-token cl-x))) (aref cl-x 8))) nil] 9 (#$ . 7996)]) (put 'oauth2-token-access-response 'compiler-macro 'oauth2-token-access-response--cmacro) #@73 Access slot "access-response" of `oauth2-token' struct CL-X. (fn CL-X) (defalias 'oauth2-token-access-response #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 8] 5 (#$ . 8459)]) (byte-code "\300\301\302\303#\304\305\306\"\207" [function-put oauth2-token-access-response side-effect-free t defalias copy-oauth2-token copy-sequence] 4) #@176 compiler-macro for inlining `make-oauth2-token'. (fn CL-WHOLE &cl-quote &key PLSTORE PLSTORE-ID CLIENT-ID CLIENT-SECRET ACCESS-TOKEN REFRESH-TOKEN TOKEN-URL ACCESS-RESPONSE) (defalias 'make-oauth2-token--cmacro #[385 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\300\305\"A@\300\306\"A@\300\307\"A@\300\310\"A@\211\203`\211@\311>\203H\211AA\262\2025\312\n>A@\203W\313\262\2025\314\315@\"\210\2025\210\316\317\320\313 \313        & \207" [plist-member :plstore :plstore-id :client-id :client-secret :access-token :refresh-token :token-url :access-response (:plstore :plstore-id :client-id :client-secret :access-token :refresh-token :token-url :access-response :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:plstore :plstore-id :client-id :client-secret :access-token :refresh-token :token-url :access-response)" cl--defsubst-expand (plstore plstore-id client-id client-secret access-token refresh-token token-url access-response) (cl-block make-oauth2-token (record 'oauth2-token plstore plstore-id client-id client-secret access-token refresh-token token-url access-response))] 24 (#$ . 8886)]) (put 'make-oauth2-token 'compiler-macro 'make-oauth2-token--cmacro) #@156 Constructor for objects of type `oauth2-token'. (fn &key PLSTORE PLSTORE-ID CLIENT-ID CLIENT-SECRET ACCESS-TOKEN REFRESH-TOKEN TOKEN-URL ACCESS-RESPONSE) (defalias 'make-oauth2-token #[128 "\300\301\"A@\300\302\"A@\300\303\"A@\300\304\"A@\300\305\"A@\300\306\"A@\300\307\"A@\300\310\"A@\211\203`\211@\311>\203H\211AA\262\2025\312\n>A@\203W\313\262\2025\314\315@\"\210\2025\210\316\317        & \207" [plist-member :plstore :plstore-id :client-id :client-secret :access-token :refresh-token :token-url :access-response (:plstore :plstore-id :client-id :client-secret :access-token :refresh-token :token-url :access-response :allow-other-keys) :allow-other-keys nil error "Keyword argument %s not one of (:plstore :plstore-id :client-id :client-secret :access-token :refresh-token :token-url :access-response)" record oauth2-token] 19 (#$ . 10128)]) (byte-code "\300\301\302\303#\304\305\306\307\310\306\311\312\305\303& \207" [function-put make-oauth2-token side-effect-free t cl-struct-define oauth2-token nil cl-structure-object record ((cl-tag-slot) (plstore) (plstore-id) (client-id) (client-secret) (access-token) (refresh-token) (token-url) (access-response)) cl-struct-oauth2-token-tags] 11) #@205 Request OAuth access at TOKEN-URL. The CODE should be obtained with `oauth2-request-authorization'. Return an `oauth2-token' structure. (fn TOKEN-URL CLIENT-ID CLIENT-SECRET CODE &optional REDIRECT-URI) (defalias 'oauth2-request-access #[1284 "\205?\300\301\205\302P\303\304\305 \206\306!\307\260\"\310\311\312\313\314\236A\315\316 \236A\317\320\f&\f\262\207" [oauth2-make-access-request "client_id=" "&client_secret=" "&code=" "&redirect_uri=" url-hexify-string "urn:ietf:wg:oauth:2.0:oob" "&grant_type=authorization_code" make-oauth2-token :client-id :client-secret :access-token access_token :refresh-token refresh_token :token-url :access-response] 19 (#$ . 11365)]) #@96 Refresh OAuth access TOKEN. TOKEN should be obtained with `oauth2-request-access'. (fn TOKEN) (defalias 'oauth2-refresh-access #[257 "\301!>\204\302\303\304D\"\210\211\211\305\306\307\301!>\204%\302\303\304D\"\210\310H\311\301!>\204:\302\303\304\nD\"\210\312H\301 !>\204O\302\303\304 D\"\210\313H\205m\314\301\n!>\204h\302\303\304\fD\"\210 \313HP\315\301 !>\204\302\303\304 D\"\210\n\316H\317\260\"\236AI\266\301!>\204\233\302\303\304D\"\210\211\320H\211\203\321\301!>\204\264\302\303\304D\"\210\322H\323\324\301!>\204\312\302\303\304 D\"\210\305H\325\301 !>\204\340\302\303\304 D\"\210\316H\326\301 !>\204\366\302\303\304 D\"\210\n\327H\257$\210\330!\210\210\207" [cl-struct-oauth2-token-tags type-of signal wrong-type-argument oauth2-token 5 access_token oauth2-make-access-request 7 "client_id=" 3 4 "&client_secret=" "&refresh_token=" 6 "&grant_type=refresh_token" 1 plstore-put 2 nil :access-token :refresh-token :access-response 8 plstore-save] 15 (#$ . 12071)]) #@122 Authenticate application via OAuth2. (fn AUTH-URL TOKEN-URL CLIENT-ID CLIENT-SECRET &optional SCOPE STATE REDIRECT-URI) (defalias 'oauth2-auth #[1796 "\300\301 \n   %%\207" [oauth2-request-access oauth2-request-authorization] 17 (#$ . 13120)]) (byte-code "\300\301\302\303\304DD\305\306\307\310\311&\207" [custom-declare-variable oauth2-token-file funcall function #[0 "\301P\207" [user-emacs-directory "oauth2.plstore"] 2] "File path where store OAuth tokens." :group oauth2 :type file] 8) #@117 Compute an unique id based on URLs. This allows to store the token in an unique way. (fn AUTH-URL TOKEN-URL SCOPE) (defalias 'oauth2-compute-id #[771 "\300\301Q\"\207" [secure-hash md5] 8 (#$ . 13633)]) #@144 Request access to a resource and store it using `plstore'. (fn AUTH-URL TOKEN-URL SCOPE CLIENT-ID CLIENT-SECRET &optional REDIRECT-URI STATE) (defalias 'oauth2-auth-and-store #[1797 "\302!\303#\304\"A\211\2030\305\306\n\n\307\310\"\307\311\"\307\n\312\"& \207\313\n\n  \f  &\314! >\204P\315\316\306D\"\210\211\211\317I\266\314! >\204g\315\316\306D\"\210\211\211\320I\266\321\322\310\314! >\204\204\315\316\306D\"\210\323H\311\314! >\204\231\315\316\306\nD\"\210\324H\312\314\n! >\204\257\315\316\306\fD\"\210 \325H\257$\210\326!\210\207" [oauth2-token-file cl-struct-oauth2-token-tags plstore-open oauth2-compute-id plstore-get record oauth2-token plist-get :access-token :refresh-token :access-response oauth2-auth type-of signal wrong-type-argument 1 2 plstore-put nil 5 6 8 plstore-save] 24 (#$ . 13847)]) #@45 Append access token to URL. (fn TOKEN URL) (defalias 'oauth2-url-append-access-token #[514 "\211\302\303\304\305#)\266\203\203\306\202\302\307\310! >\204'\311\312\313D\"\210\314HR\207" [inhibit-changing-match-data cl-struct-oauth2-token-tags "?" nil t string-match "&" "access_token=" type-of signal wrong-type-argument oauth2-token 5] 10 (#$ . 14723)]) (defvar oauth--url-advice nil) #@63 Return `Authoriztions: Bearer' header with TOKEN. (fn TOKEN) (defalias 'oauth2-authz-bearer-header #[257 "\300\301\302\"B\207" ["Authorization" format "Bearer %s"] 5 (#$ . 15129)]) #@78 Return EXTRA-HEADERS with `Authorization: Bearer' added. (fn EXTRA-HEADERS) (defalias 'oauth2-extra-headers #[257 "\302\303@! >\204\304\305\306@D\"\210@\307H!B\207" [oauth--token-data cl-struct-oauth2-token-tags oauth2-authz-bearer-header type-of signal wrong-type-argument oauth2-token 5] 6 (#$ . 15318)]) #@28 (fn ORIG-FUN &rest ARGS) (defalias 'oauth2--url-http-handle-authentication-hack #[385 "\204 \306\"\207 \n\307 ! \310@!\210\311A#\210\312\313!\203+\314 +\314\207" [oauth--url-advice url-http-method url-http-data url-http-extra-headers url-request-extra-headers url-request-data apply oauth2-extra-headers oauth2-refresh-access url-retrieve-internal boundp success t url-request-method oauth--token-data url-callback-function url-callback-arguments] 6 (#$ . 15638)]) (advice-add 'url-http-handle-authentication :around 'oauth2--url-http-handle-authentication-hack) #@175 Retrieve an URL synchronously using TOKEN to access it. TOKEN can be obtained with `oauth2-auth'. (fn TOKEN URL &optional REQUEST-METHOD REQUEST-DATA REQUEST-EXTRA-HEADERS) (defalias 'oauth2-url-retrieve-synchronously #[1282 "B\305\306!\307!-\207" [oauth--token-data url-request-extra-headers url-request-data url-request-method oauth--url-advice t oauth2-extra-headers url-retrieve-synchronously] 10 (#$ . 16227)]) #@262 Retrieve an URL asynchronously using TOKEN to access it. TOKEN can be obtained with `oauth2-auth'. CALLBACK gets called with CBARGS when finished. See `url-retrieve'. (fn TOKEN URL CALLBACK &optional CBARGS REQUEST-METHOD REQUEST-DATA REQUEST-EXTRA-HEADERS) (defalias 'oauth2-url-retrieve #[1795 "B\305\306!\307#-\207" [oauth--token-data url-request-extra-headers url-request-data url-request-method oauth--url-advice t oauth2-extra-headers url-retrieve] 12 (#$ . 16662)]) (provide 'oauth2)