# Invalid access token

**URL:** <https://devforum.zoom.us/t/invalid-access-token/7153>\
**Category:** API and Webhooks\
**Created:** [December 20, 2019, 4:21pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153 "2019-12-20T16:21:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![moustaphaosman](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/moustaphaosman/32/2649_2.png) [@moustaphaosman](https://devforum.zoom.us/u/moustaphaosman)\
**Post date:** [December 20, 2019, 4:21pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/1 "2019-12-20T16:21:16Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/1/15b65f4ce929cc3434debe1f8a20a97dd56d9caa.png)

Thanks,  
MO

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [December 20, 2019, 5:26pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/2 "2019-12-20T17:26:31Z")

</div>

Hey @moustaphaosman,

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

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![moustaphaosman](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/moustaphaosman/32/2649_2.png) [@moustaphaosman](https://devforum.zoom.us/u/moustaphaosman)\
**Post date:** [December 20, 2019, 7:45pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/3 "2019-12-20T19:45:29Z")

</div>

HI Tommy,

the request URL is: [https://glass.ihrdc.com/chat\_API/zoomPHP/zoomGet.php](https://glass.ihrdc.com/chat_API/zoomPHP/zoomGet.php)

and CURLOPT\_URL =\> "[https://api.zoom.us/v2/chat/users/me/messages](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](https://marketplace.zoom.us/docs/api-reference/zoom-api/im-chat/sendimmessages)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/a/a7d4379b48ad452dc020a22562d41c29b9f77aad.png)

and the message didn’t work as well

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [December 20, 2019, 9:43pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/4 "2019-12-20T21:43:34Z")

</div>

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](https://marketplace.zoom.us/docs/api-reference/zoom-api/chat-messages/sendachatmessage)

Double check you are using a User Level OAuth app.

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![moustaphaosman](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/moustaphaosman/32/2649_2.png) [@moustaphaosman](https://devforum.zoom.us/u/moustaphaosman)\
**Post date:** [December 23, 2019, 9:00pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/5 "2019-12-23T21:00:00Z")

</div>

Hi @tommy

I tried [https://marketplace.zoom.us/docs/api-reference/zoom-api/chat-messages/sendachatmessage](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

---

<div class="post-metadata">

**Author:** ![moustaphaosman](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/moustaphaosman/32/2649_2.png) [@moustaphaosman](https://devforum.zoom.us/u/moustaphaosman)\
**Post date:** [December 24, 2019, 4:32pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/6 "2019-12-24T16:32:28Z")

</div>

@tommy,

I got it to work used the the following function:

```auto
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

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [December 26, 2019, 4:23pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/7 "2019-12-26T16:23:40Z")

</div>

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! 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![moustaphaosman](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/moustaphaosman/32/2649_2.png) [@moustaphaosman](https://devforum.zoom.us/u/moustaphaosman)\
**Post date:** [January 3, 2020, 3:10pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/8 "2020-01-03T15:10:14Z")

</div>

@tommy Thank you so much!

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [January 3, 2020, 5:59pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/9 "2020-01-03T17:59:14Z")

</div>

Happy to help! 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 7:08pm UTC](https://devforum.zoom.us/t/invalid-access-token/7153/10 "2020-08-21T19:08:38Z")

</div>


