Skip to content

Instantly share code, notes, and snippets.

@tassoman
Last active November 11, 2025 12:13
Show Gist options
  • Select an option

  • Save tassoman/91339a4300264348253161e7ec2d4bba to your computer and use it in GitHub Desktop.

Select an option

Save tassoman/91339a4300264348253161e7ec2d4bba to your computer and use it in GitHub Desktop.
#!/bin/sh
###
#
# This script creates an App token to automate your profile in #FEDIVERSE
# with PLEROMA / AKKOMA / PL / NICOLEX
#
# Author: Tassoman <tassoman@gmail.com>
# License: AGPLv3
# See: https://gist.github.com/tassoman/91339a4300264348253161e7ec2d4bba
#
###
SCOPES='read write follow'
if ! command -v jq >/dev/null 2>&1; then
echo " . Warning: jq is not installed. Please install jq to enable full functionality." >&2
# optional: exit 1
exit 1
fi
if [ "$#" = "2" ]; then
RESPONSE_APP=$(curl --silent -XPOST -F "client_name=$2" -F "redirect_uris=urn:ietf:wg:oauth:2.0:oob" -F "scopes=$SCOPES" https://$1/api/v1/apps)
CLIENT_ID=$(echo $RESPONSE_APP | jq -r .client_id)
CLIENT_SECRET=$(echo $RESPONSE_APP | jq -r .client_secret)
echo " . "
# echo " . Client id: $CLIENT_ID"
# echo " . Client secret: $CLIENT_SECRET"
echo " . Now open this following URI in browser: \n . https://$1/oauth/authorize?client_id=$CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=$(echo $SCOPES | sed s/\ /+/g)"
echo " . After you get the authentication token, re-run this script: "
echo "$0 $1 $2 $CLIENT_ID $CLIENT_SECRET <authentication token that you received>"
elif [ "$#" = "5" ]; then
FINAL_RESPONSE=$(curl --silent -X POST -F "client_id=$3" -F "client_secret=$4" -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' -F "code=$5" -F 'grant_type=authorization_code' -F "scope=$SCOPES" https://$1/oauth/token)
echo " . "
echo " . App $2 Secret Token is: $(echo $FINAL_RESPONSE | jq -r .access_token)"
else
echo "Usage: $0 <instance_domain> <appname>"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment