Authentication for Twitch API
#Client ID: --***--- | |
#Client Secret: ---***--- | |
#Client ID and Client Secret are sensititve and you should not share them | |
client_id= <yourclientid> | |
client_secret= <yourclientsecret> | |
#Request for the access code using requests library | |
#I have chosen this method of authentication with my goal in mind | |
access_code = requests.post('https://id.twitch.tv/oauth2/token?client_id='+str(client_id)+'&client_secret='+str(client_secret)+'&grant_type=client_credentials') | |
#access token response is a JSON-encoded app access token | |
access_token = json.loads(access_code.text) | |
access_token = access_token['access_token'] | |
#Sample response is | |
""" | |
{ | |
"access_token": "prau3ol6mg5glgek8m89ec2s9q5i3i", | |
"refresh_token": "", | |
"expires_in": 3600, | |
"scope": [], | |
"token_type": "bearer" | |
} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment