Skip to content

Instantly share code, notes, and snippets.

@kaivalyapowale
Last active December 17, 2019 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaivalyapowale/f295c57268d114cd12f4d794be43607f to your computer and use it in GitHub Desktop.
Save kaivalyapowale/f295c57268d114cd12f4d794be43607f to your computer and use it in GitHub Desktop.
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