# The ID in moderator\_id must match the user ID found in the request's OAuth token

**URL:** <https://discuss.dev.twitch.com/t/the-id-in-moderator-id-must-match-the-user-id-found-in-the-requests-oauth-token/44501>\
**Category:** API\
**Created:** [March 27, 2023, 3:22pm UTC](https://discuss.dev.twitch.com/t/the-id-in-moderator-id-must-match-the-user-id-found-in-the-requests-oauth-token/44501 "2023-03-27T15:22:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dynamix](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dynamix/32/12476_2.png) [@Dynamix](https://discuss.dev.twitch.com/u/Dynamix)\
**Post date:** [March 27, 2023, 3:22pm UTC](https://discuss.dev.twitch.com/t/the-id-in-moderator-id-must-match-the-user-id-found-in-the-requests-oauth-token/44501/1 "2023-03-27T15:22:11Z")

</div>

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}](https://api.twitch.tv/helix/users?login=%24%7Bname%7D) endpoint.  
In Authorization: `Bearer ${token}` I am using the access token I got in the endpoint `[https://id.twitch.tv/oauth2/token](https://id.twitch.tv/oauth2/token)

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

```

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 27, 2023, 3:25pm UTC](https://discuss.dev.twitch.com/t/the-id-in-moderator-id-must-match-the-user-id-found-in-the-requests-oauth-token/44501/2 "2023-03-27T15:25:26Z")

</div>

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

> [@Dynamix](#):
>
> I cannot find the user id in the OAuth token request

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

---

<div class="post-metadata">

**Author:** ![Dynamix](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dynamix/32/12476_2.png) [@Dynamix](https://discuss.dev.twitch.com/u/Dynamix)\
**Post date:** [March 27, 2023, 4:35pm UTC](https://discuss.dev.twitch.com/t/the-id-in-moderator-id-must-match-the-user-id-found-in-the-requests-oauth-token/44501/3 "2023-03-27T16:35:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [April 26, 2023, 4:36pm UTC](https://discuss.dev.twitch.com/t/the-id-in-moderator-id-must-match-the-user-id-found-in-the-requests-oauth-token/44501/4 "2023-04-26T16:36:39Z")

</div>

Closed on April 26, 2023, 4:36pm UTC

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