Adding Users to Array and OAuth Token Expiring

Hi! This is a two part question.

I’m trying to add users automatically (when requested) to an array and hopefully not having to refresh my code for a chatbot. The only way I can think of is to manually load the Twitch user names and then reload the program. I’m thinking there is a better/automated way to do this?

And the second part, is my oauth token keeps expiring after a few days. I thought oauth tokens were supposed to last a few weeks? Is anyone else having this problem and if so, is there a good/best practice I should be following?

I’m new to coding so sorry if these questions seem basic. Thank you for your time!

A “normal” user token is 4 hours
A “implicit” user token is 60 days.

If you generate 50 tokens (for the same user) when you generate the 51st it’ll kill the first one.
Which sounds like what is going on here.

Add users and do what with the information?

Add users and do what with the information?

I want to add the users to the array so the chatbot knows to enters their chat. Not sure the best way to implement this. This is completely voluntary on the user’s part.

Theres a number of options

If the joining mechanism is that users go to the bots own channel and writes !join then you can read that from chat.

If the joining mechanism is a website then you need to devise a way to send messages to a running instance of the bot. Personally I use Redis PubSub to send messages in/out of a running instance.

But you could also add the user to a database and have the bot check the database for changes every minute or so.

A “normal” user token is 4 hours
A “implicit” user token is 60 days.

If you generate 50 tokens (for the same user) when you generate the 51st it’ll kill the first one.
Which sounds like what is going on here.

This makes sense, how do I get an implicit user token?

Sorry for so many questions and thank you for your help!

err don’t you already have it.

generally a chat bot will use a “normal” token as a “normal” token can be infinitely refresh.

An “implicit” token will require the user to manaully provide a token when the token expires and not a thing chat bots would normally use

So is there a better way or automatic way to refresh the token that follows best practice? Or should I create an alert when the token expires?

  1. With your token call the validation endpoint - Validating Tokens | Twitch Developers
  2. If the token is invalid, then use the refresh token to get a new token - Refreshing Access Tokens | Twitch Developers

But you could also add the user to a database and have the bot check the database for changes every minute or so.

So I can basically have the user added to the array when they join and automatically refresh the script if there is a change to the array?

No need to “refresh” or restart.

Just send a join command. no need to restart.