3 read -p "Instance URL (e.g https://example.com): " INSTANCE_URL
5 echo "Creating oauth app..."
9 $INSTANCE_URL/api
/v
1/apps \
11 --data-urlencode 'client_name=fedibash' \
12 --data-urlencode 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' \
13 --data-urlencode 'scopes=admin:metrics' \
14 --header "Content-Type: application/x-www-form-urlencoded"
17 client_id
=$(echo $RESP | jq -r .client_id)
18 client_secret
=$(echo $RESP | jq -r .client_secret)
20 if [ -z "$client_id" ]; then
21 echo "Could not create an app"
26 echo "Please visit the following URL and input the code provided"
27 AUTH_URL
="$INSTANCE_URL/oauth/authorize?client_id=$client_id&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=admin:metrics&response_type=code"
28 if [ ! -z "$BROWSER" ]; then
36 echo "Requesting code..."
40 $INSTANCE_URL/oauth
/token \
42 --header "Content-Type: application/x-www-form-urlencoded" \
43 --data-urlencode "client_id=$client_id" \
44 --data-urlencode "client_secret=$client_secret" \
45 --data-urlencode "code=$CODE" \
46 --data-urlencode "grant_type=authorization_code" \
47 --data-urlencode 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
48 --data-urlencode "scope=admin:metrics"
51 ACCESS_TOKEN
="$(echo $RESP | jq -r .access_token)"
53 echo "Token is $ACCESS_TOKEN"
54 DOMAIN
=$(echo $INSTANCE_URL | sed -e 's/^https:\/\///')
56 echo "Use the following config in your prometheus.yml:
60 credentials: $ACCESS_TOKEN
61 metrics_path: /api/v1/akkoma/metrics