[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/url-http-oauth-demo f2d8a1a4bb 02/13: url-http-oauth-de
|
From: |
Thomas Fitzsimmons |
|
Subject: |
[elpa] externals/url-http-oauth-demo f2d8a1a4bb 02/13: url-http-oauth-demo-get-profile-name is working |
|
Date: |
Mon, 8 May 2023 21:25:11 -0400 (EDT) |
branch: externals/url-http-oauth-demo
commit f2d8a1a4bb6c40d0488abe2fb7b3e938392419d6
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
url-http-oauth-demo-get-profile-name is working
* url-http-oauth-demo.el: Call url-http-oauth-register-resource.
(url-http-oauth-demo-get-api-version): New function.
(url-http-oauth-demo-get-profile-name): Likewise.
---
url-http-oauth-demo.el | 41 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/url-http-oauth-demo.el b/url-http-oauth-demo.el
index 902475f37a..4874a290cc 100644
--- a/url-http-oauth-demo.el
+++ b/url-http-oauth-demo.el
@@ -36,14 +36,49 @@
;;; Register "https://meta.sr.ht/query" as needing OAuth 2.0 for
;;; authentication.
;;;###autoload
-(url-http-oauth-register-provider "https://meta.sr.ht/query"
+(url-http-oauth-register-resource "https://meta.sr.ht/query"
"https://meta.sr.ht/oauth2/authorize"
"https://meta.sr.ht/oauth2/access-token"
"107ba4a9-2a96-4420-8818-84ec1f112405"
"meta.sr.ht/PROFILE:RO")
-;; FIXME: Make an authenticated API call using "meta.sr.ht/PROFILE:RO"
-;; to prove the OAuth 2.0 procedure was successful.
+;;;###autoload
+(defun url-http-oauth-demo-get-api-version ()
+ "Asynchronously retrieve the Sourcehut GraphQL API version.
+Print the HTTP status and response in *Messages*."
+ (interactive)
+ (let ((url-request-method "POST")
+ (url-request-extra-headers
+ (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"
+ status (buffer-string))))))
+
+;;;###autoload
+(defun url-http-oauth-demo-get-profile-name ()
+ "Asynchronously retrieve the Sourcehut profile name.
+Print the result to *Messages*."
+ (interactive)
+ (let ((url-request-method "POST")
+ (url-request-extra-headers
+ (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))))))
(provide 'url-http-oauth-demo)
- [elpa] branch externals/url-http-oauth-demo created (now ee91889a8e), Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo 828ef46e55 05/13: Add background documentation, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo 8ea929c685 10/13: Update config format and Emacs 26 support, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo d14fc3e005 07/13: Update url-http-oauth-interpose call, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo d45c47de23 03/13: Make get-profile-name function synchronous, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo a2b9116412 11/13: Use updated settings format, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo f2d8a1a4bb 02/13: url-http-oauth-demo-get-profile-name is working,
Thomas Fitzsimmons <=
- [elpa] externals/url-http-oauth-demo 8ba62b2072 08/13: Update a comment, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo de81100f6e 04/13: Finish confidential client demonstration, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo bcbea4d8ef 06/13: Change scope handling, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo d5ebb7e14f 01/13: url-http-oauth-demo.el: New package, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo ee91889a8e 13/13: Bump version to 1.0.0, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo 68dd6973b2 12/13: Update comments, Thomas Fitzsimmons, 2023/05/08
- [elpa] externals/url-http-oauth-demo aa62f012d0 09/13: Fix URL retrieval, Thomas Fitzsimmons, 2023/05/08