Apologies if I’m missing something obvious, but I’m trying to access the Streams API in Helix.
1 I get client-credentials through the id.twitch.tv endpoint, like so:
auth_url = "https://id.twitch.tv/oauth2/token?client_id=" + client_id + "&client_secret=" + client_secret + "&grant_type=client_credentials"
r = requests.post(auth_url, timeout=15)
r.raise_for_status()
info = r.json()
client_token = info['access_token']
This returns the token just fine.
2 Then, I pass this on to the endpoint:
headers = {
'Client_ID': client_id,
'Authorization': 'Bearer ' + client_token,
}
helix_url = "https://api.twitch.tv/helix/streams?first=20"
helix_r = requests.get(helix_url, headers, timeout = 15)
helix_r.raise_for_status()
stream_info = helix_r.json()
print(stream_info)
And I get a 401 error. The message body says the “OAuth token is missing”.
What am I missing? Thanks in advance.