Skip to content

Instantly share code, notes, and snippets.

@ringtailsoftware
Created November 8, 2022 22:57
Show Gist options
  • Select an option

  • Save ringtailsoftware/28c93c85dcb3df5e6dd528c4c41ff1b0 to your computer and use it in GitHub Desktop.

Select an option

Save ringtailsoftware/28c93c85dcb3df5e6dd528c4c41ff1b0 to your computer and use it in GitHub Desktop.
Mastodon Toot Shell Script
#!/bin/bash
MASTODON_SERVER=https://mastodon.social
MASTODON_USERNAME=foo@bar.com
MASTODON_PASSWORD=secretpassword
CLIENT_NAME=myclient # anything you like
CLIENT_URL=http://myclient.com # anything you like
APP=`curl -X POST -d "client_name=$CLIENT_NAME&redirect_uris=urn:ietf:wg:oauth:2.0:oob&scopes=write read follow&website=$CLIENT_URL" $MASTODON_SERVER/api/v1/apps`
CLIENT_ID=`echo $APP | jq -r .client_id`
CLIENT_SECRET=`echo $APP | jq -r .client_secret`
echo $CLIENT_ID $CLIENT_SECRET
TOKENJSON=`curl -X POST -d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=password&username=$MASTODON_USERNAME&password=$MASTODON_PASSWORD&scope=write read follow" -Ss $MASTODON_SERVER/oauth/token`
echo $TOKENJSON
ACCESS_TOKEN=`echo $TOKENJSON | jq -r .access_token`
echo $ACCESS_TOKEN
curl -XPOST --header "Authorization: Bearer $ACCESS_TOKEN" -d 'status=Hello World' -sS $MASTODON_SERVER/api/v1/statuses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment