Invalid access token

Hi ,

I am getting
{“code”:4700,“message”:“Invalid access token, does not contain scopes: [chat_message:write, zms:chat_message:write]”}

even that I have added the scopes in my app

Thanks,
MO

Hey @moustaphaosman,

Can you please share your request url and which endpoint is throwing that error?

Thanks,
Tommy

HI Tommy,

the request URL is: https://glass.ihrdc.com/chat_API/zoomPHP/zoomGet.php

and CURLOPT_URL => "https://api.zoom.us/v2/chat/users/me/messages

I also tried from https://marketplace.zoom.us/docs/api-reference/zoom-api/im-chat/sendimmessages

and the message didn’t work as well

Hey @moustaphaosman,

As the IM API endpoints are being deprecated next month, please try using the new endpoint: https://marketplace.zoom.us/docs/api-reference/zoom-api/chat-messages/sendachatmessage

Double check you are using a User Level OAuth app.

Thanks,
Tommy

Hi @tommy

I tried https://marketplace.zoom.us/docs/api-reference/zoom-api/chat-messages/sendachatmessage
posting directly the form at the end of the page and I got
{
“code”: 4700,
“message”: “Invalid access token, does not contain scopes: [chat_message:write, zms:chat_message:write]”
}

the chatbot I am using is a “Account-level app” what do I should to reply to users messages in chatbot

thanks,
MO

@tommy,

I got it to work used the the following function:

function getAccessToken() {
	global $token_url, $client_id, $client_secret;

	$content = "grant_type=client_credentials";
	$authorization = base64_encode("$client_id:$client_secret");
	$header = array("Authorization: Basic {$authorization}","Content-Type: application/x-www-form-urlencoded");

	$curl = curl_init();
	curl_setopt_array($curl, array(
		CURLOPT_URL => $token_url,
		CURLOPT_HTTPHEADER => $header,
		CURLOPT_SSL_VERIFYPEER => false, // important
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_POST => true,
		CURLOPT_POSTFIELDS => $content
	));
	$response = curl_exec($curl);
	//echo $response;
	curl_close($curl);
	return json_decode($response)->access_token;
} 

and then add the this line to function example from zoom dev site

CURLOPT_SSL_VERIFYPEER => false,

thank you so much!
MO

1 Like

Hey @moustaphaosman,

Happy to hear you got it working! Due note that the Chat and Channel APIs are only compatible with a User Level OAuth app at the moment.

Let us know if you have any other questions! :slight_smile:

Thanks,
Tommy

1 Like

@tommy Thank you so much!

1 Like

Happy to help! :slight_smile:

Thanks,
Tommy