diff options
Diffstat (limited to 'lisp/mastodon-auth.el')
-rw-r--r-- | lisp/mastodon-auth.el | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index d01f687..2d11d46 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -1,8 +1,22 @@ +;;; mastodon-auth.el --- Auth functions for mastodon.el + +;;; Commentary: + +;; mastodon.el is an Emacs client for Mastodon, the federated microblogging +;; social network. It is very much a work-in-progress, but it is a labor of +;; love. + +;; mastodon-auth.el supports authorizing and authenticating with Mastodon. + +;;; Code: + +(require 'plstore) (require 'mastodon) (require 'mastodon-http) (defgroup mastodon-auth nil "Authenticate with Mastodon." + :prefix "mastodon-auth-" :group 'mastodon) (defvar mastodon--client-app-plist nil) @@ -21,7 +35,7 @@ STATUS is passed by `url-retrieve'." ,(gethash "client_secret" client-data))))))) (defun mastodon--register-client-app () - "Adds `:client_id' and `client_secret' to `mastodon--client-plist'." + "Add `:client_id' and `client_secret' to `mastodon--client-plist'." (mastodon--http-post (mastodon--api-for "apps") 'mastodon--register-client-app-triage '(("client_name" . "mastodon.el") @@ -29,13 +43,13 @@ STATUS is passed by `url-retrieve'." ("scopes" . "read write follow")))) (defun mastodon--register-and-return-client-app () - "Registers `mastodon' with an instance. Returns `mastodon--client-app-plist'." + "Register `mastodon' with an instance. Return `mastodon--client-app-plist'." (progn (mastodon--register-client-app) mastodon--client-app-plist)) (defun mastodon--store-client-id-and-secret () - "Stores `:client_id' and `:client_secret' in a plstore." + "Store `:client_id' and `:client_secret' in a plstore." (let ((client-plist (mastodon--register-and-return-client-app)) (plstore (plstore-open mastodon-token-file))) (plstore-put plstore "mastodon" `(:client_id @@ -47,7 +61,7 @@ STATUS is passed by `url-retrieve'." client-plist)) (defun mastodon--client-app () - "Returns `mastodon--client-app-plist'. + "Return `mastodon--client-app-plist'. If not set, retrieves client data from `mastodon-token-file'. If no data can be found in the token file, registers the app and stores its data via `mastodon--store-client-id-and-secret'." @@ -75,9 +89,9 @@ STATUS is passed by `url-retrieve'." mastodon--api-token-string))))) (defun mastodon--get-access-token () - "Retrieves access token from instance. Authenticates with email address and password. + "Retrieve access token from instance. -Email address and password are not stored." +Authenticates with email address and password. Neither are not stored." (mastodon--http-post (concat mastodon-instance-url "/oauth/token") 'mastodon--get-access-token-triage `(("client_id" . ,(plist-get (mastodon--client-app) :client_id)) @@ -88,7 +102,7 @@ Email address and password are not stored." ("scope" . "read write follow")))) (defun mastodon--access-token () - "Returns `mastodon--api-token-string'. + "Return `mastodon--api-token-string'. If not set, retrieves token with `mastodon--get-access-token'." (if mastodon--api-token-string @@ -101,3 +115,4 @@ If not set, retrieves token with `mastodon--get-access-token'." mastodon--api-token-string))) (provide 'mastodon-auth) +;;; mastodon-auth.el ends here |