Unauthorized - 401 - Insufficient authorization in token

“error”: “Unauthorized”,
“status”: 401,
“message”: “Insufficient authorization in token”

I get the JSON above after doing a request on https://api.twitch.tv/helix/moderation/moderators with the right headers and query below,

headers: {
  "Client-ID": process.env.CLIENT_ID,
  Authorization: "Bearer " + accessToken,
qs: {
  broadcaster_id: "90849777",

I checked that the client-id was good, the token was good and the broadcaster_id too so I don’t understand why it says there’s insufficient authorization in token because I succeeded to get the JSON object with the accessToken, expiresIn, scope, token_type properties.

Docs : https://dev.twitch.tv/docs/api/reference#get-moderators

That would suggest one of the following

  • You used an App Access Token/Client Credentials
  • You used a token that does not have moderation:read attached
  • You used a token that doesn’t belong to 90849777 aka versifixion

You need a User Access Token belonging to 90849777 -> https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-authorization-code-flow

To attach the moderation:read, you have to put in in the URL like this right ?

Link : https://id.twitch.tv/oauth2/authorize?client_id=5fhz51tfvoevwmrn39ity7iv99vqa9&redirect_uri=http://localhost:3000&response_type=code&scope=moderation:read%20user:read:follows&force_verify=true

That looks correct yes. That requests the user:read:follows scope and the moderation:read scope

Ok, and I want to display my moderators on my website, so yes my broadcaster_id is 90849777 (username VersifiXion), but above you said 908497771 ? You added a 1 at the end ?

I fat fingered and missed the ` and hit the 1 and didn’t notice. My mistake (post edited)

I figured what was the issue… I was connected with another Twitch account… Thank you for the time you spent on this topic :sweat_smile:

But can you tell me that if another user comes into my website, he will still get my moderators ?

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