if you're seeing this then I managed to toot from Clojure. \o/

(http/post
(str (uri/join (:host @toot-cat) "/api/v1/statuses"))
{:form-params {:status "if you're seeing this then I managed to toot from Clojure. \o/"}
:headers "Authorization" (str "Bearer " access-token)})

Sweet! That actually worked :D :D

Had to poke around in both the Mastodon and the Doorkeeper sources to figure out this OAuth flow but I managed.

Did it with plain clj-http, might try again using clj-oauth now that I get it.

Here's the code https://gist.github.com/plexus/789814cf2bd4dd57c8f1b738d68e7b1e

Lessons learned

- OAuth2 is fidgety af (no news there, really)
- include redirect_uri everywhere, even though it's only used once
- when creating the app it's redirect_uris and scopes (both plural), in the auth link it's both singular
- lots of 422 or 401 with no meaningful error message whatsoever. Luckily I could run a local instance to debug.