Unable to connect to Twitch Chat with OAuth Token

I’m working on code for a chatbot application for broadcasters that would ideally be able to send messages to the broadcaster’s channel as the broadcaster.

My application currently uses the OAuth Authorization Code Grant Flow (from what I can tell) to get OAuth tokens for broadcasters and refreshes the OAuth tokens before they expire. I should theoretically always have a valid OAuth token for the broadcaster (barring disconnections on Twitch side and what not). I believe I have the correct scope/permissions when the broadcaster goes through the OAuth flow. I have tried to use a broadcaster OAuth token for connecting to Twitch chat, but I get a “Login Unsuccessful” message. I have tested this application with the chatbot Twitch account and token for that, and it works with that information, but not using the OAuth token for the broadcaster’s account.

Here’s an example of my token (quickly revoked after I got this information) and the scopes associated with it:

Okay, it seems to be that I’m missing the “chat:read” scope specifically. It seems that “chat:edit” is not a “super scope” that by default includes the “chat:read” scope.

The scopes needed are documented. for example https://dev.twitch.tv/docs/irc/authenticate-bot/ specifies

The scopes that you specify when requesting the token depends on your bot’s functionality. If the bot just reads chat messages, it only needs the chat:read, but if it also sends messages, it’ll need the chat:edit scope, too.

It’s also mentioned a few other places in the Chat docs too, such as Getting Started.

In general, if multiple scopes can be used then multiple scopes will be listed, for example Get Guest Star Session has:

  • Requires OAuth Scope: channel:read:guest_star, channel:manage:guest_star, moderator:read:guest_star or moderator:manage:guest_star

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