Using API for setTitle get Unauthorized (Javascript)

Hello Twitch Developers,

I’m a small developer who recently created an account to build a Twitch bot (in JS). I’ve been working on a bot that can manage various aspects of a Twitch channel, including updating the stream title using the channel:manage:broadcast scope.

The bot works perfectly on its own channel, where it is the broadcaster. However, when I try to use the same command on my main Twitch channel, where the bot is set as both a moderator and an editor, I receive an “Unauthorized” error.

Here’s a summary of the issue:

  • The bot has the channel:manage:broadcast scope.
  • The bot is a broadcaster on its own channel and successfully updates the stream title.
  • On my main channel, where the bot is set as a moderator and editor, it fails to update the stream title and returns an “Unauthorized” error.

Here’s how my code work:

  • channelId : work properly on each twitch channel
  • I have implemented a check in the bot to verify a user’s role when they issue a command

Has anyone else experienced this issue, or does anyone have insights on why this might be happening? I appreciate any help or guidance you can provide.

Thank you in advance !

Becuase the API requires a token from the broadcaster.

An editor or moderator token is not sufficent.

Any bot that can update the channel title has a token for the broadcaster on file and uses that token, not it’s own

The ID of the broadcaster whose channel you want to update. This ID must match the user ID in the user access token.

Which only does when your code is updating the bot’s own channel as that is the token you used.

1 Like

To be honest, I forgot about the second part when I returned to work on my command. Thank you!

So I realize I need to add something to request the token.
I should implement an Authorization Code Flow to resolve my issue with a database.

Thank you for your time and answer !

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