diff options
Diffstat (limited to 'lisp/mastodon-auth.el')
-rw-r--r-- | lisp/mastodon-auth.el | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 28c14bc..e9889d9 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -43,6 +43,9 @@ (defvar mastodon-auth--token-alist nil "Alist of User access tokens keyed by instance url.") +(defvar mastodon-auth--acct-alist nil + "Alist of account accts (name@domain) keyed by instance url.") + (defun mastodon-auth--generate-token () "Make POST to generate auth token." (mastodon-http--post @@ -79,5 +82,20 @@ Generate token and set if none known yet." (push (cons mastodon-instance-url token) mastodon-auth--token-alist))) token)) +(defun mastodon-auth--get-account-name () + "Request user credentials and return an account name." + (cdr (assoc + 'acct + (mastodon-http--get-json + (mastodon-http--api + "accounts/verify_credentials"))))) + +(defun mastodon-auth--user-acct () + "Return a mastodon user acct name." + (or (cdr (assoc mastodon-instance-url mastodon-auth--acct-alist)) + (let ((acct (mastodon-auth--get-account-name))) + (push (cons mastodon-instance-url acct) mastodon-auth--acct-alist) + acct))) + (provide 'mastodon-auth) ;;; mastodon-auth.el ends here |