I have been successfully writing a twitch chat bot up until the point I tried to set stream tags.
I made a website where to enable the OAuth flow and retrieve the access token. I request multiple scopes, including user:edit:boardcast
I start the OAuth to retrieve access and refresh token (redirect_uri removed):
https://id.twitch.tv/oauth2/authorize?client_id=xxxxxxxxxxxxxxxxxxxx&redirect_uri=https://XXXXXXXX.com/auth/twitch/callback&response_type=code&scope=user%3Aread%3Abroadcast%20user%3Aedit%3Abroadcast%20channel%3Amoderate%20chat%3Aedit%20chat%3Aread%20whispers%3Aread%20whispers%3Aedit%20channel_read%20channel_editor%20user%3Aread%3Aemail
So we see here there is user:edit:broadcast
URI encoded. Attempts at not URI encoding the scopes seem to be ignored by the browser and in any case I have removed other URI encoded scopes and can then start getting 401s on requests requiring those scopes.
So I receive the callback server-side and save the access token.
I wrote some code to iterate through all stream tags and pull out the tags I am interested in by id. I also get my user id. I then attempt to update the stream tags (client ID and access token removed):
headers:
{ Accept: 'application/vnd.twitchtv.v5+json',
'Content-Type': 'application/json;charset=utf-8',
'Client-ID': 'XXXXXXXX',
Authorization: 'OAuth XXXXXXXX',
'User-Agent': 'axios/0.17.1',
'Content-Length': 14 },
method: 'put',
url: 'https://api.twitch.tv/helix/streams/tags?broadcaster_id=143343300',
data: '{"tag_ids":["6f86127d-6051-4a38-94bb-f7b475dde109"]}' },
No matter what I seem to always get a 401 error response with message: 'Missing scope: user:edit:broadcast'
I have tried removing other scopes, for example chat:edit
and chat:read
and sure enough I am no longer able to connect to chat websocket with the same OAuth.
Not sure what else to try at this point…