Last active
December 17, 2019 14:47
-
-
Save kaivalyapowale/f295c57268d114cd12f4d794be43607f to your computer and use it in GitHub Desktop.
Authentication for Twitch API
This file contains 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
#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