feat: added tokenmaker script for bash
This commit is contained in:
parent
a7a1daaabe
commit
1808e98450
1 changed files with 35 additions and 0 deletions
35
scripts/tokenmaker.sh
Executable file
35
scripts/tokenmaker.sh
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$#" -eq 2 ]; then
|
||||||
|
EMAIL="$1"
|
||||||
|
PASSWORD="$2"
|
||||||
|
else
|
||||||
|
read -r -p "username : " EMAIL
|
||||||
|
read -r -s -p "password (silent) : " PASSWORD
|
||||||
|
echo ''
|
||||||
|
fi
|
||||||
|
|
||||||
|
HEADERS="Content-Type: application/json"
|
||||||
|
PAYLOAD="{\"username\":\"$EMAIL\",\"password\":\"$PASSWORD\"}"
|
||||||
|
|
||||||
|
AUTH_TOKEN=$(curl -s -d "$PAYLOAD" -H "$HEADERS" -X POST https://authserver.mojang.com/authenticate)
|
||||||
|
|
||||||
|
if [[ -z "$AUTH_TOKEN" ]]; then
|
||||||
|
echo "[!] empty response from auth server"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $AUTH_TOKEN == *ForbiddenOperationException* ]]; then
|
||||||
|
echo "[!] invalid credentials"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v jq &> /dev/null
|
||||||
|
then
|
||||||
|
echo "$AUTH_TOKEN"
|
||||||
|
else
|
||||||
|
ACCESSTOKEN=$(echo "$AUTH_TOKEN" | jq .accessToken)
|
||||||
|
CLIENTTOKEN=$(echo "$AUTH_TOKEN" | jq .clientToken)
|
||||||
|
echo "accessToken: $ACCESSTOKEN"
|
||||||
|
echo "clientToken: $CLIENTTOKEN"
|
||||||
|
fi
|
Loading…
Reference in a new issue