whatsnowplaying / whats-now-playing

Titling software for streamers who use DJ software like Serato, Virtual DJ, and more.
MIT License
58 stars 11 forks source link

twitch redemptions cycling authentication #748

Open aw-was-here opened 1 year ago

aw-was-here commented 1 year ago

Twitch auth may get caught in a loop with the following stack trace:

2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot pubsub:start:137 DEBUG pubsub started up!
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot twitch:__api_get_request:490 DEBUG making GET request to https://api.twitch.tv/helix/users?login=USER
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot pubsub:__send_listen:212 DEBUG sending listen for topics
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot pubsub:__send_message:230 DEBUG sending message
2023-03-28T14:08:02-0700 16552 twitchbot/Thread-5 (__run_socket) pubsub:__task_receive:305 DEBUG received message {"type":"RESPONSE","error":"ERR_BADAUTH","nonce":"42637f13-652d-4653-acc8-0a53903af95f"}
2023-03-28T14:08:02-0700 16552 twitchbot/Thread-5 (__run_socket) pubsub:__handle_response:343 DEBUG got response for nonce 42637f13-652d-4653-acc8-0a53903af95f: PubSubResponseError.BAD_AUTH
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot redemptions:run_redemptions:159 DEBUG Traceback (most recent call last):
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot redemptions:run_redemptions:159 DEBUG   File "nowplaying\twitch\redemptions.py", line 154, in run_redemptions
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot redemptions:run_redemptions:159 DEBUG   File "twitchAPI\pubsub.py", line 473, in listen_channel_points
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot redemptions:run_redemptions:159 DEBUG   File "twitchAPI\pubsub.py", line 263, in __generic_listen
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot redemptions:run_redemptions:159 DEBUG   File "twitchAPI\pubsub.py", line 224, in __send_listen
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot redemptions:run_redemptions:159 DEBUG twitchAPI.types.TwitchAuthorizationException
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot redemptions:run_redemptions:160 ERROR pubsub listen_channel_points failed
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot twitch:refresh_used_token:363 DEBUG refreshing user token
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot utils:save_refreshed_tokens:140 DEBUG Twitch tokens refreshed and saved
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot utils:api_logout:152 DEBUG TWITCH shutdown
2023-03-28T14:08:02-0700 16552 twitchbot/TwitchBot utils:cache_token_del:167 DEBUG Broken twitch config. Removing any cached API tokens.

... and then it tries again, which fails in the exact same way and on and on. I suspect the cached tokens actually aren't getting removed and/or pyTwitchAPI isn't actually getting new tokens.

aw-was-here commented 1 year ago

We figured out that this situation occurs when the bot user is trying to access the wrong stream. (e.g., browser is logged into wrong user).