Created
May 25, 2023 23:44
-
-
Save 0187773933/862c6709d47d6c483b6e7e6fc7ec59ef to your computer and use it in GitHub Desktop.
Twitch Helix API Stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CLIENT_ID="asdf" | |
CLIENT_SECRET="asdf" | |
REDIRECT_URI="http://localhost:3033/" | |
# 1.) refresh client credentials ( this is a less permissive client credential auth token ) | |
# curl -s -X POST 'https://id.twitch.tv/oauth2/token' \ | |
# -H 'Content-Type: application/x-www-form-urlencoded' \ | |
# -d 'client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=client_credentials' | |
# Should Return : | |
# {"access_token":"asdf","expires_in":5404915,"token_type":"bearer"} | |
ACCESS_TOKEN="asdf" | |
# 2.A) generate an authorization_code ( this is a special user signed access token ) | |
# https://id.twitch.tv/oauth2/authorize?client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI&response_type=code&scope=user:read:email user:read:broadcast user:edit:broadcast user:edit channel:read:subscriptions analytics:read:extensions analytics:read:games bits:read channel:edit:commercial channel:manage:broadcast channel:manage:extensions channel:manage:redemptions channel:manage:polls channel:manage:predictions channel:moderate chat:edit chat:read clips:edit moderation:read whispers:read whispers:edit | |
USER_AUTHORIZATION_CODE="asdf" | |
# 2.B) generate authorization_code_access_token | |
# curl -s -X POST https://id.twitch.tv/oauth2/token \ | |
# -d client_id=$CLIENT_ID \ | |
# -d client_secret=$CLIENT_SECRET \ | |
# -d code=$USER_AUTHORIZATION_CODE \ | |
# -d grant_type=authorization_code \ | |
# -d redirect_uri= | |
# Should Return : | |
# {"access_token":"asdf","expires_in":14833,"refresh_token":"asdf","scope":["analytics:read:extensions","analytics:read:games","bits:read","channel:edit:commercial","channel:manage:broadcast","channel:manage:extensions","channel:manage:polls","channel:manage:predictions","channel:manage:redemptions","channel:moderate","channel:read:subscriptions","chat:edit","chat:read","clips:edit","moderation:read","user:edit","user:edit:broadcast","user:read:broadcast","user:read:email","whispers:edit","whispers:read"],"token_type":"bearer"} | |
USER_ACCESS_TOKEN="asdf" | |
# 3.) Get Your User-ID | |
# USER_ID=$(curl -s -H "Authorization: Bearer $USER_ACCESS_TOKEN" -H "Client-Id: $CLIENT_ID" -X GET "https://api.twitch.tv/helix/users" | jq -r ".data[0].id" ) | |
# echo $USER_ID | |
USER_ID="asdf" | |
# 4.) Get Your Live Followers ( first page ) | |
LIVE_FOLLOWERS=$( curl -s -H "Authorization: Bearer $USER_ACCESS_TOKEN" -H "Client-Id: $CLIENT_ID" -X GET "https://api.twitch.tv/helix/users/follows?from_id=$USER_ID" | jq -r ".data[].to_login" ) | |
printf "%s\n" $( echo "$LIVE_FOLLOWERS" | sort ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment