Skip to content.
Joe Heaton's Webzone
🥐 ☕
Online since 2011

OAuth with Mastodon & Pleroma

Mastodon & Pleroma are federated social networks, in order to pull statistics I needed to use OAuth2.

First we need an OAuth app, this can be done either as a HTTP request or via the admin tools.

curl -X POST \
	-F 'client_name=Test' \
	-F 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' \
	-F 'scopes=read' \
	-F 'website=' \

Scopes can be any combination of: read, write, follow, push.1

For Pleroma, you can use pleroma_ctl to create your OAuth app2.

./bin/pleroma_ctl app create -n APP_NAME -s read -r REDIRECT_URI

Now to request an Authorization token via the OAuth API:

curl -X POST \
  -F 'client_id=ABC' \
  -F 'client_secret=XYZ' \
  -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
  -F 'grant_type=client_credentials'

Insert your values in the fields client_id, client_secret and set your domain name.1

Success! You can use this token to make requests against the Mastodon & Pleroma API!

  1. ↩︎

  2. ↩︎

Joe Heaton

Email: [email protected]


Joe’s technology-focused murmurings.
comments powered by Disqus