26 lines
752 B
Bash
Executable File
26 lines
752 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Configuration
|
|
USERNAME="admin" # Replace with your username
|
|
PASSWORD="wasamasa123" # Replace with your password
|
|
TOKEN_FILE="$HOME/.pastebin_token"
|
|
API_URL="https://paste.priet.us/api/token" # Update with your actual API URL
|
|
|
|
# Refresh the token
|
|
response=$(curl -s -X POST "$API_URL" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"username\":\"$USERNAME\", \"password\":\"$PASSWORD\"}")
|
|
|
|
# Extract the token from the response
|
|
token=$(echo "$response" | jq -r .token)
|
|
|
|
# Check if the token was retrieved successfully
|
|
if [[ "$token" == "null" || -z "$token" ]]; then
|
|
echo "Failed to refresh token" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Save the token to the file
|
|
echo "$token" > "$TOKEN_FILE"
|
|
echo "Token refreshed successfully: $TOKEN_FILE"
|