Not sure what happened, but I can’t seem to authenticate at all. I’ve checked to make sure the client_id and client_secret are correct, so don’t think that’s it. The POST to “https://id.twitch.tv/oauth2/token” returns a 404.
Code:
auth_url = “https://id.twitch.tv/oauth2/token”
validate_url = “https://id.twitch.tv/oauth2/validate”
client_id = "REMOVED"
client_secret = "REMOVED"
auth_params = {'client_id': client_id, 'client_secret': client_secret, 'grant_type':'client_credentials'}
token = "REMOVED"
validate_headers = {'client-id': client_id, 'Authorization': 'OAuth ' + token }
headers = {'client-id': client_id, 'Authorization': 'Bearer ' + token }
valid = requests.get(validate_url, headers=validate_headers).json()
print(valid)
if 'status' in valid and valid['status'] == 401:
print ("Token not valid")
else:
print ("Token still valid")
def getkey(try_number=1):
try:
key = requests.put(auth_url, params=auth_params).json()
except (requests.exceptions.ConnectionError, json.decoder.JSONDecodeError):
time.sleep(1)
return getkey(try_number=try_number+1)
else:
return key
stream = getkey(try_number=1)
print (stream)
The recursive function is to catch intermittent JSONDecode errors, but right now, it’s the only error I’m getting because the output of the token request 404’s.
Anyone else having the same issue?
Edit: Python, using requests.