Valid token, unsuccessful login with tmi.js

Hi everyone,

I’m trying to make a simple twitch bot and I’m trying to use an authentication flow to get my oauth token. After getting this token, I can validate it and it returns a status 200. In the response it states my client_id.

To make sure tmi.js is not trying to connect to the server first (without any token), I’m waiting on the token with await, and this works fine.

However, when calling client.connect() on the tmi client, I get the following:
[01:09] info: Connecting to irc-ws.chat.twitch.tv on port 443…
[01:09] info: Sending authentication to server…
[01:09] error: Login unsuccessful

Does anyone know why this happens and how I can solve this?

Which authentication flow?

Only a user access token can login to chat when authenticating as a user

This sounds like you have used an App Access Token instead

Hi Barry,

I’m indeed using an App Access Token as I would like to have my bot act on its own rather than on my behalf. So I used the client credentials flow. Is it possible to use tmi in this way? Or does it only work for users?

The “bot” needs to exist as a “user on Twitch”

Then you go thru the user authentication flow whilst logged into the Twitch Website as the bot to get the tokens you need.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.