diff options
author | Abhiseck Paira <abhiseckpaira@disroot.org> | 2021-12-28 14:58:44 +0530 |
---|---|---|
committer | Abhiseck Paira <abhiseckpaira@disroot.org> | 2022-01-13 19:38:38 +0530 |
commit | 03365c8fbaac2c71e6bbfed731ae88d551175c2c (patch) | |
tree | a2ad3dd873f9425327ea14a08fe76ed963071a9d /lisp/mastodon-client.el | |
parent | 89add914c9e10979c271cdbb5f4af076ecbe41db (diff) |
abstract Mastodon API request info
Mastodon API requires some info that needs to be passed during app
registration and user authentication. Those info were hard coded into
various functions.
Introduce three variables (defvars):
1. mastodon-client-scopes
2. mastodon-client-website
3. mastodon-client-redirect-uri
use them to abstract those info.
Also refactor `mastodon-client--register' function in terms of these
variables.
Diffstat (limited to 'lisp/mastodon-client.el')
-rw-r--r-- | lisp/mastodon-client.el | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index b27d434..9fb45f7 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -46,14 +46,23 @@ (defvar mastodon-client--client-details-alist nil "An alist of Client id and secrets keyed by the instance url.") +(defvar mastodon-client-scopes "read write follow" + "Scopes to pass to oauth during registration.") + +(defvar mastodon-client-website "https://codeberg.org/martianh/mastodon.el" + "Website of mastodon.el.") + +(defvar mastodon-client-redirect-uri "urn:ietf:wg:oauth:2.0:oob" + "Redirect_uri as required by oauth.") + (defun mastodon-client--register () "POST client to Mastodon." (mastodon-http--post (mastodon-http--api "apps") - '(("client_name" . "mastodon.el") - ("redirect_uris" . "urn:ietf:wg:oauth:2.0:oob") - ("scopes" . "read write follow") - ("website" . "https://github.com/jdenen/mastodon.el")) + `(("client_name" . "mastodon.el") + ("redirect_uris" . ,mastodon-client-redirect-uri) + ("scopes" . ,mastodon-client-scopes) + ("website" . ,mastodon-client-website)) nil :unauthenticated)) |