However, I was told that using Twitch Chat Password Generator is a bad idea. Unfortunately, I can’t figure out how to get the equivalent by reading the Twitch API docs.
Strangely, Twitch’s own documentation recommends using that URL:
The token to authenticate your chatbot with Twitch’s servers. Generate this with Twitch Chat Password Generator (a Twitch community-driven wrapper around the Twitch API), while logged in to your chatbot account. The token will be an alphanumeric string.
To say that this is confusing is an understatement.
You need to implement the oAuth loop yourself. For user Auth, that a bot would use, this means you need to throw up a webpage somewhere that handles the initial oAuth loop.
Normally you would use
As this provides a user token and a refresh token, so you oAuth once, store the two tokens then use the refresh token as needed. (oAuth validity for a chat bot is checked at bot connected to chat, so you only need to refresh when the bot boots before it connects to chat). Normally this token is valid for four hours, but when it expires the bot is not disconnected from chat.
This is intended so you can get started with running the example bot code quickly and skip learning authentication. You wouldn’t use this in production/on a live bot, as twithcapps uses implicit auth, which doesn’t give you a refresh token, so every 60 days you then have to manually go thru their flow to get a new token and load it in. And sods law $bigStreamer is using your bot, they go live and you haven’t loaded in the new oAuth token and they have no bot.
As the bot can’t auto remake the token with the client secret/refresh token, since you don’t get those from twitchapps
Not sure if this will be of any use to you MountainRiderAK, it seems you have some issue with the Oauth logic and implementation with Python.
I got an open PR with a WIP Twitch connector for opsdroid, perhaps you could have a look at the code and see what I am doing, bear in mind that this is a WIP PR so I am probably going to change things around still.
Let me also mention that in the PR we are using async code and I am using aiohttp.websockets support - if everything that you need is to listen to the chat server then the code that you want is the connect_websocket.
Also I am currently using user oauth tokens instead of app one and will change things around in the very near future. In regards to getting the access_token and how I am getting my access token locally you can have a quick look at the documentation on that PR it should explain things a bit - this will be removed in the future.