branch: externals/url-http-oauth-demo commit d45c47de2364d2879cd183b531602b57bd2d8244 Author: Thomas Fitzsimmons <fitz...@fitzsim.org> Commit: Thomas Fitzsimmons <fitz...@fitzsim.org>
Make get-profile-name function synchronous * url-http-oauth-demo.el: Use new registration client-secret-required argument. (url-http-oauth-demo-get-profile-name): Fix indentation. Change debug message. Make synchronous. --- url-http-oauth-demo.el | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/url-http-oauth-demo.el b/url-http-oauth-demo.el index 4874a290cc..5b13e0bd91 100644 --- a/url-http-oauth-demo.el +++ b/url-http-oauth-demo.el @@ -40,7 +40,8 @@ "https://meta.sr.ht/oauth2/authorize" "https://meta.sr.ht/oauth2/access-token" "107ba4a9-2a96-4420-8818-84ec1f112405" - "meta.sr.ht/PROFILE:RO") + "meta.sr.ht/PROFILE:RO" + 'prompt) ;;;###autoload (defun url-http-oauth-demo-get-api-version () @@ -49,13 +50,13 @@ Print the HTTP status and response in *Messages*." (interactive) (let ((url-request-method "POST") (url-request-extra-headers - (list (cons "Content-Type" "application/json") + (list (cons "Content-Type" "application/json") (cons "Authorization" "Bearer abcd"))) (url-request-data "{\"query\": \"{ version { major, minor, patch } }\"}")) (url-retrieve "https://meta.sr.ht/query" (lambda (status) - (message "%S, %S" + (message "GET-API-VERSION: %S, %S" status (buffer-string)))))) ;;;###autoload @@ -65,20 +66,18 @@ Print the result to *Messages*." (interactive) (let ((url-request-method "POST") (url-request-extra-headers - (list (cons "Content-Type" "application/json"))) + (list (cons "Content-Type" "application/json"))) (url-request-data "{\"query\": \"{ me { canonicalName } }\"}")) - (url-retrieve "https://meta.sr.ht/query" - (lambda (status) - (message "STR: %s" (buffer-string)) - (goto-char (point-min)) - (re-search-forward "\n\n") - - (let* ((result (json-parse-buffer)) - ;;(me (gethash "me" result)) - ;;(name me) - ) - (message "%S" result)))))) + (with-current-buffer (url-retrieve-synchronously "https://meta.sr.ht/query") + (message "GET-PROFILE-NAME: %s" (buffer-string)) + (goto-char (point-min)) + (re-search-forward "\n\n") + (let* ((result (json-parse-buffer)) + ;;(me (gethash "me" result)) + ;;(name me) + ) + (message "GET-PROFILE-NAME PARSED: %S" result))))) (provide 'url-http-oauth-demo)