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=https://pleroma.heaton.dev' \
https://mastodon.example/api/v1/apps
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' https://pleroma.example.org/oauth/token
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!