branch: externals/url-http-oauth-demo
commit d5ebb7e14f6ed4a02f02c99db23780026e7b7beb
Author: Thomas Fitzsimmons <[email protected]>
Commit: Thomas Fitzsimmons <[email protected]>
url-http-oauth-demo.el: New package
* url-http-oauth-demo.el: New file.
* .gitignore: Likewise.
---
.gitignore | 3 +++
url-http-oauth-demo.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..fa7b465de0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/url-http-oauth-demo-pkg.el
+/url-http-oauth-demo-autoloads.el
+*.elc
diff --git a/url-http-oauth-demo.el b/url-http-oauth-demo.el
new file mode 100644
index 0000000000..902475f37a
--- /dev/null
+++ b/url-http-oauth-demo.el
@@ -0,0 +1,50 @@
+;;; url-http-oauth-demo.el --- Demo url-http-oauth -*- lexical-binding: t -*-
+
+;; Copyright (C) 2023 Free Software Foundation, Inc.
+
+;; Author: Thomas Fitzsimmons <[email protected]>
+;; Version: 0
+;; Keywords: comm, data, processes, hypermedia
+;; Package-Requires: ((url-http-oauth "0"))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This package demonstrates an OAuth 2.0 flow for Sourcehut using the
+;; built-in GNU Emacs URL library and the GNU ELPA url-http-oauth
+;; package.
+;;
+;; Installation:
+;;
+;; M-x package-install RET url-http-oauth-demo RET
+
+;;; Code:
+(require 'url-http-oauth)
+
+;;; Register "https://meta.sr.ht/query" as needing OAuth 2.0 for
+;;; authentication.
+;;;###autoload
+(url-http-oauth-register-provider "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.
+
+(provide 'url-http-oauth-demo)
+
+;;; url-http-oauth-demo.el ends here