How to read messages from chat using tmi?

From what you describe it’s a flat no go

You need an external portal that viewers/users go to in order to retrived codes/secrets

Seperate to the external portal that streamers use to add your bot to their channel

That is the purpose of Twitch oAuth really, people login to the external portal with their Twitch Account. No secret code needed, jsut go “hey X you can login to the portal now”. Don’t give them a code to “sign up” to the portal just when they login check if they are on the allowed list.

No need to do any code exchangement…

This is essentially how “sub only external portals” work, just instead of checking if they are a sub to x channel, check if they have been granted access on x channel (which is all your secret code stuff is doing anyway)

Extensions start here Extensions | Twitch Developers