The ID in moderator_id must match the user ID found in the request's OAuth token

Hello,

I have a problem when using the Ban user endpoint,
this problem does not occur in my chat (as broadcaster), but it occurs wherever my bot has a mod,

I have moderator:manage:banned_users scope enabled.

I cannot find the user id in the OAuth token request

I am using broadcaster_id and moderator_id from https://api.twitch.tv/helix/users?login=${name} endpoint.
In Authorization: Bearer ${token} I am using the access token I got in the endpoint `https://id.twitch.tv/oauth2/token

  error: 'Unauthorized',
  status: 401,
  message: "The ID in moderator_id must match the user ID found in the request's OAuth token."

This means the token you are using is

  • not a user token
  • not a user token belonging to the moderator_id in the request

So, for example

  • moderator: barrycarlyon - user_id = 15185913
  • channel: cohhcarnage - user_id = 26610234

Using a user token that represents barrycarlyon with the relevant scopes attached

broadcaster_id in request 26610234
moderator_id in request 15185913
Token is barrycarlyon’s token

Not sure what you mean, if you call the users endpoint without an ID/username then you’ll get the user back if the token is of type user
Or call the validate token endpoint

OK. thank you,
I was using token that represents broadcaster, when i change it to token that represents bot, it work :smiley:

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