jim2k
1
Hello,
I always have a missing authorization when I try to make a raid with the twitch API.
Here is the code :
// Launch the raid
try {
const raid = await axios.post(
`https://api.twitch.tv/helix/raids?from_broadcaster_id=${FROM}&to_broadcaster_id=${TO}`,
{
headers: {
Authorization: `Bearer ${token}`,
"Client-ID": CLIENT_ID,
},
}
);
console.log("raid result", raid);
} catch (error) {
console.log("Error when raiding");
}
Any idea ? I’m struggling !
Parse the body of the error response to determine the issue.
Could be a problem with the token not having sufficent scopes
Of your From/to are usernames instead of userIDs
Or the to_broadcaster_id is rejecting raids from from_broadcaster_id
So you need to process the error.
jim2k
3
Hello,
Thanks for the answer.
The exact error is always the same
data: {
error: 'Unauthorized',
status: 401,
message: 'OAuth token is missing'
}
But i’d like to say that I can get others ressouces like user channel information with the same token.
The scope of my token is : scope: [ 'channel:manage:raids' ]
And impossible for rejecting the raid, both acc belongs to me 
Any idea ?
Then either token is blank.
Or your axios call is malformed.
jim2k
5
The token is not blank.
What is the problem with my call ?
I cant figure it out.
From google → stackoverflow
Using the shortcut axios.post function, argument 2 is for POST body data. and argument 3 is for configuration.
So with your current code you will have POST’ed the ClientID and AccessToken as body not as headers.
But I don’t use AXIOS so this is speculation
jim2k
7
oh yes true,
I’ve made this mistake, thank you.
But still not working with this:
try {
const headers = {
Authorization: `Bearer ${token}`,
"Client-Id": CLIENT_ID,
};
const raid = await axios.post(
`https://api.twitch.tv/helix/raids`,
{
from_broadcaster_id: FROM,
to_broadcaster_id: TO,
},
{
headers,
}
);
console.log("raid result", raid);
} catch (error) {
console.log("Error when raiding =>", error);
}
I’m still looking for the problem
Still telling me that the Oauth token is missing
Whats the error being reported now?
jim2k
9
Actually it’s not the same anymore, it was message: 'OAuth token is missing' and now it is message: 'Missing User OAUTH Token'
This suggests you have generated and used an app access/client credentials token instead of a user token.
To perform user operations you generally need a user access token
Either Implicit grant flow or Authorization code grant flow