I coded a discord bot containing twitch.py with twitch helix a few months ago. Now im trying to start the Bot but get the following error:
Traceback (most recent call last):
File “H:/pythonProject/Bot/Bot.py”, line 13, in
from twitch import get_notifications
File “H:\pythonProject\Bot\twitch.py”, line 23, in
print(get_app_access_token())
File “H:\pythonProject\Bot\twitch.py”, line 20, in get_app_access_token
access_token = response.json()[“access_token”]
KeyError: ‘access_token’
Yes. The client secret was the problem i think. But theres another error:
Traceback (most recent call last):
File “H:/pythonProject/Bot/Bot.py”, line 13, in
from twitch import get_notifications
File “H:\pythonProject\Bot\twitch.py”, line 80, in
users = get_users(config[“watchlist”])
File “H:\pythonProject\Bot\twitch.py”, line 41, in get_users
return {entry[“login”]: entry[“id”] for entry in response.json()[“data”]}
KeyError: ‘data’
Suggests that response to your helix users doesn’t contain a data key
As it didn’t 200 Ok and returned an error.
So you need to fix your code to detect and handle errors more gracefully than just a “data doesn’t exist” key error.