Hello! I’m asking this question because I got stuck on this problem and I’m not sure how to solve it.
- I get the Type
Barertoken using the route: ‘https://id.twitch.tv/oauth2/token’, which returns me:
{
access_token: 'dummy_token_1',
expires_in: 5034336,
token_type: 'bearer'
}
- With this token I retrieve the
idusing the route https://api.twitch.tv/helix/users?login=jaguaronfire, which would be the same as thebroadcaster_id, right?:
{
data: [
{
id: '999999999', // <-- this guy
login: 'jaguaronfire',
display_name: 'jaguaronfire',
type: '',
broadcaster_type: 'affiliate',
description: '',
profile_image_url: '',
offline_image_url: '',
view_count: 0,
created_at: '2023-07-03T21:40:14Z'
}
]
}
- With this information, having make the channel show a commercial:
const resp = await fetch('https://api.twitch.tv/helix/channels/commercial', {
method:"POST",
headers:{
Authorization:'Bearer dummy_token_1',
"Client-Id":"my_client_id",
"Content-Type":"application/json"
},
body:JSON.stringify({
broadcaster_id:"99999999",
length:30
})
})
However, I receive the following message:
{
error: 'Unauthorized',
status: 401,
message: "The ID in broadcaster_id must match the user ID found in the request's OAuth token."
}
What should I have done to get the id correctly? I’m not understanding this.
Just for observation:
The application was created within the channel account I’m trying to access.
