# How to access Zoom API with chat bot?

**URL:** <https://devforum.zoom.us/t/how-to-access-zoom-api-with-chat-bot/60397>\
**Category:** API and Webhooks\
**Created:** [November 18, 2021, 3:36am UTC](https://devforum.zoom.us/t/how-to-access-zoom-api-with-chat-bot/60397 "2021-11-18T03:36:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohith](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@rohith](https://devforum.zoom.us/u/rohith)\
**Post date:** [November 18, 2021, 3:36am UTC](https://devforum.zoom.us/t/how-to-access-zoom-api-with-chat-bot/60397/1 "2021-11-18T03:36:30Z")

</div>

## Using this template helps us debug your issues more effectively 🙂

**Description**  
I have created a chatbot Application and able send and receive messages using grant type client credentials. but could get any authorisation code to access Zoom API.

**Error**  
{ code: 200, message: ‘Invalid api key or secret.’ }

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
Chat Bot

here is the main code:

```auto
app.get('/authorize', (req, res) => {
    res.redirect('https://zoom.us/launch/chat?jid=robot_' + process.env.zoom_bot_jid);
});
app.post('/bot', (req, res) => {
    getChatbotToken();
    function getChatbotToken () {
        request({
          url: `https://zoom.us/oauth/token?grant_type=client_credentials`,
          method: 'POST',
          headers: {
            'Authorization': 'Basic ' + Buffer.from(process.env.zoom_client_id + ':' + process.env.zoom_client_secret).toString('base64')
          }
        }, (error, httpResponse, body) => {
          if (error) {
            console.log('Error getting chatbot_token from Zoom.', error)
          } else {
            body = JSON.parse(body)
            console.log(body.access_token);
            sendChat(body.access_token)
          }
        })
      }
      function sendChat (chatbotToken) {

        request({
            url: 'https://api.zoom.us/v2/users/',
            method: 'GET',
            json: true,
            headers: {
              'Content-Type': 'application/json',
              'Authorization': 'Bearer ' + chatbotToken
            }
          }, (error, response, body) => {
            if (error) {
              console.log('Error sending chat.', error);
            } else {
              console.log(body);
            }
          })
      } 
});

```

Thanks rohith

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [November 19, 2021, 12:50pm UTC](https://devforum.zoom.us/t/how-to-access-zoom-api-with-chat-bot/60397/2 "2021-11-19T12:50:59Z")

</div>

Hi @rohith,

If you’re calling the Zoom REST APIs, you will need to use a separate access\_token from an OAuth app with specific scopes, retrieved using the authorization\_code grant type instead. A Chatbot app will only be able to access certain Chat related APIs.

Let me know if this helps to clarify,  
Will

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [December 19, 2021, 10:51pm UTC](https://devforum.zoom.us/t/how-to-access-zoom-api-with-chat-bot/60397/3 "2021-12-19T22:51:31Z")

</div>

Closed on December 19, 2021, 10:51pm UTC

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