What's the correct way to have the client automatically renew tokens? #413
-
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
For the token you pass in for the main Bot / Client to connect to IRC you need to validate / refresh that yourself on startup. For API / Helix calls you can use the below event in your main bot subclass, this is obviously just a basic example as everyone has their own infrastructure to store tokens, refresh_tokens and so on.
|
Beta Was this translation helpful? Give feedback.
-
I gave this a try, and I don't think that this event ever actually fires. I added a log line at the very beginning, and it never gets printed, and the code I added to update the tokens on disk never runs. I'm not sure what I'm doing wrong here. For reference, this is what the log looks like when it begins to fail:
It then continues to attempt to reconnect indefinitely, despite the token being bad. |
Beta Was this translation helpful? Give feedback.
-
I'm confused about how to apply the new credentials to the Client. I don't see any methods for this. Are you supposed to disconnect the bot and spin up a new client every time you refresh the token? |
Beta Was this translation helpful? Give feedback.
As I mentioned above, it's for Helix / API calls only, not the main chatbot token.
You need to handle refreshing that yourself for now in 2.x