# Missing Scope for Ban User Request - Except it's not missing!

**URL:** <https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868>\
**Category:** API\
**Created:** [November 16, 2023, 12:09am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868 "2023-11-16T00:09:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katarina\_Wyatt](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/katarina_wyatt/32/11206_2.png) [@Katarina\_Wyatt](https://discuss.dev.twitch.com/u/Katarina_Wyatt)\
**Post date:** [November 16, 2023, 12:09am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868/1 "2023-11-16T00:09:42Z")

</div>

Can someone who has some sleep recently and knows what they’re doing help me out with this problem?  
I’m trying to create a script to remove lurking bots from the channel after one of our frequent gift sub givers complained about accidentally giving subs to bots. The response I’m getting from my script is that the ‘moderator:manage:banned\_users’ scope is missing except it isn’t, it is in the callback script and it’s been authorized for our web app by the broadcaster - I know because I did it myself on his computer by logging in and out again on our website and the authorization update request was there and included the moderator:manage:banned\_users scope.

Here’s my code - in case that is responsible for the error.

```auto
	$BAN = curl_init();	
	$databody = array(   
		'user_id' => $whoID,
		'reason' => 'bot',
	);
	$datain = array('data'=> $databody);
	$data = json_encode($datain);
	
	curl_setopt($BAN, CURLOPT_URL, "https://api.twitch.tv/helix/moderation/bans?broadcaster_id=501071947&moderator_id=501071947");
	curl_setopt($BAN, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($BAN, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($BAN, CURLOPT_HTTPHEADER, array(  
		'Authorization: Bearer '.$authtoken, 
		'Client-Id: '.$clientid, 
		'Content-type: application/json',  
		
	));   
	curl_setopt($BAN, CURLOPT_POST,true);
	curl_setopt($BAN, CURLOPT_POSTFIELDS,$data);
	$BANresult = json_decode(curl_exec($BAN),true);
	echo curl_error($BAN);
	curl_close($BAN);
	var_dump($BANresult);

```

---

<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:** [November 16, 2023, 12:12am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868/2 "2023-11-16T00:12:20Z")

</div>

You did generate a USER access token and not a CLIENT CREDENTIALS/App Access token?

And the token of type user belongs to `501071947`

---

<div class="post-metadata">

**Author:** ![Katarina\_Wyatt](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/katarina_wyatt/32/11206_2.png) [@Katarina\_Wyatt](https://discuss.dev.twitch.com/u/Katarina_Wyatt)\
**Post date:** [November 16, 2023, 12:15am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868/3 "2023-11-16T00:15:17Z")

</div>

Yes and yes

---

<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:** [November 16, 2023, 12:17am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868/4 "2023-11-16T00:17:59Z")

</div>

Drop the token `$authtoken` into a tool such as [Token Checker | Twitch API Example](https://barrycarlyon.github.io/twitch_misc/examples/token_checker/) and check it’s what you think it is.

As I don’t have anything else obvious other than the token is wrong somewhere.

---

<div class="post-metadata">

**Author:** ![Katarina\_Wyatt](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/katarina_wyatt/32/11206_2.png) [@Katarina\_Wyatt](https://discuss.dev.twitch.com/u/Katarina_Wyatt)\
**Post date:** [November 16, 2023, 12:20am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868/5 "2023-11-16T00:20:22Z")

</div>

Token is valid - type ‘User Access’ and the scope in question is listed.

---

<div class="post-metadata">

**Author:** ![Katarina\_Wyatt](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/katarina_wyatt/32/11206_2.png) [@Katarina\_Wyatt](https://discuss.dev.twitch.com/u/Katarina_Wyatt)\
**Post date:** [November 16, 2023, 12:24am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868/6 "2023-11-16T00:24:03Z")

</div>

Ok apparently it just needed time to marinade! It’s now working…I guess I need to apply some patience! Thank you anyway Barry for your help!

---

<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:** [December 16, 2023, 12:24am UTC](https://discuss.dev.twitch.com/t/missing-scope-for-ban-user-request-except-its-not-missing/50868/7 "2023-12-16T00:24:55Z")

</div>

Closed on December 16, 2023, 12:24am UTC

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