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

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.

	$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);

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

And the token of type user belongs to 501071947

Yes and yes

Drop the token $authtoken into a tool such as Token Checker | Twitch API Example and check it’s what you think it is.

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

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

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!

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