You refer to
yeah?
The code just tells you how to do it.
But it doesn’t give an opinion on where/how to store a token.
The general flow for a “production” script is:
- Script starts
- Script sees if it has a token in storage
- If existing token exists in storage, load that token from storage
- if the token doesn’t exist or has expired
- generate a token
- Store that token
- use token to get stream status
However, for a Discord bot doing live streamer status.
You potentitally want to use EventSub instead
Then Twitch will notify you when a stream starts (or ends).
Rather than you needing to poke the API every few minutes.
Then you only generate an use an app access token when creating eventsub subscriptions.
So you’d set it up once and thats it. No more token schnanigans unless you need to remake the exsitong or make new subscriptions to new streamers live status.
However,
If you ONLY have one script total. Then always generating an App Access Token at script start is ok. As you only have the one process and won’t run into the 50 token rule.