Using twitch-js API request to change stream title / game

Hello,

I’m trying to create a chat bot using twitch-js. I generated my access token using twitchtokengenerator.com and selected all scopes for my bot account. Using chat works great, but I want to add a command to change title and game of my stream. I’m using this API request to achieve that:
api.put(‘channels/’ + channelID, { body: { channel: { status: title } }, headers: { ‘Content-Type’: ‘application/json’ } });
For some reason it always returns
{“status”:403,“message”:“Fail to auth.”,“error”:“Forbidden”,“error_code”:“error_auth_failure”}
when using my bot account.
When I generate a token for my own account it works just fine however.
Does the bot account need further authorisation?

You will need a oAuth token for channelID in order to change the title/game of channelID

Sounds like you are trying to auth as your bot and change the game/title on another channel

So I have to provide my own token instead of the bot token?

Correct.

For a bot to change the channel it belongs to

  • It logs into chat using an oAuth with chat_login for the bot in order to read/write to chat as the bot user account
  • it auths to twitch API with a oAuth for the channel with the channel_editor for the channel owner, to read/write to the channel as the channel user account

As documented here

I see. Thanks a lot for your help!

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