Using the new "Modify channel" endpoint for helix

Now that there is a helix endpoint for modifying channel information, I wanted to upgrade my chat bot a bit. But I’ve ran into a bit of a problem here. My api call looks like this

	url: '',
		broadcaster_id: broadcasterID,
		game_id: gameID,
	method: 'PATCH',
	headers: {
		Authorization: 'Bearer ' + accesstoken,
		'Client-ID': clientID
	json: true
}, (err, response, body) => {
	/* handling response */

Using this with an app accesstoken returns a 401 - unauthorized. I made sure that the token was generated with the correct scopes. So i thought, I might need to use the token I’ve generated for the bot in order to connect to Twitch IRC.
So it has the form ‘oauth:<token>’ I’ve tried putting the token into the Authorization header. I also tried to replace Bearer with OAuth like the old Authorization did. It didn’t work. So I then thought, my broadcaster_id might be wrong.
When i request my channel information, i get this:

  data: [
      id: '<id>',
      user_id: '<user_id>',
      user_name: '<name>',
      game_id: '<game_id>',
      /*  */

I’ve tried using both id and user_id but nothing worked. I’m definitely missing something here, but I can’t figure out, what exactly. Any ideas? :slight_smile:

You need a "user access token. App access tokens don’t have a user attached.

This grants you access to update the bots channel.

You need permission from the broadcaster you wish to update.

So you need

  • a user access token
  • with the user:edit:broadcast scope
  • where the user_id of the token matches the broadcaster_id in your qs

Finally this looks like NodeJS, the requests module is deprecated, you should find a new module, node-fetch, axios and got are recommended alternatives (I use got myself)

1 Like

This did the trick :smiley: thanks again.

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