Python - Edit Stream Title (401 invalid oauth token)

You should NOT I repeat NOT be logging into Twitch this way.

You should write code that allows you to auth your application to your Twitch (Bot) Account. Which provides an access token. Then you use the access token with the bot. The bot itself should NOT be logging into Twitch itself. IE two separate programs.

The bot should never have code to go and login to Twitch on it’s own.

You only need to do this step once ever… Unless you de-auth your application from the Twitch Account.

Thats not a “workaround” thats how you are supposed to do it.

People used to use and may still use a service like Twitch Chat Password Generator to generate an oAuth token for them, then the bot only needs that token, and the ability to refresh said token (which you won’t be able to do with the TMI generator), now that tokens expire. (ClientID’s made before a certain point in time don’t require refresh).

Yes but you are given a refresh token to use to get a new token (and an expires in time)

In summary, your bot only needs the code to refresh a token, it does NOT need the code to generate the token.