Unable to create channel using JWT

Using this template helps us debug your issues more effectively :slight_smile:

Description
Hello team, I created a Chatbot App (account-level app), which receives notifications via web-hooks. And then I was trying to create a channel (from Node.js server) using /chat/users/{userId}/channels API. For this API, we need to send OAuth2 code, so I tried to call the below API to get OAuth2, but it was throwing below error

Error

{“reason”:“Internal Error”,“error”:“invalid_request”}

Below is the request I am using to get OAuth2 access token

request({
url: https://zoom.us/oauth/token?grant_type=authorization_code,
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 oauth2 access_token from Zoom. ', error)
} else {
console.log(body) // this is print internal error message.
}})

And then I tried to use JWT on behalf of OAuth2 access token while creating channel as follows:

let payload = { name: "sample channel", type:2};
let res2 = await axios.post('https://api.zoom.us/v2/chat/users/'+<user_id>+'/channels', payload, { headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + <JWT Token>
} });

let data = res2.data;
console.log("Successfully created channel:", data);

In this case, it threw the below error

data: {
  code: 124,
  message: 'This API only supports oAuth2 for authorization.'
}

Below are couple of questions, I have:

  1. To create a channel, can we use JWT on behalf of OAuth2?
  2. If we can use JWT, what is the right way to do that?
  3. If we can only use OAuth2, then do we need to create one more app OAuth2 (in addition to the already existing Chatbot App)? What are the exact steps that I need to follow to be able to create a channel from node.js server?

The full error message or issue you are running into.

Which App Type (OAuth / Chatbot / JWT / Webhook)?
I have created Chatbot App. To get JWT, I also created JWT app but it didn’t help either.

Knowing the endpoint/s can help us to identify your issue faster. Please link the ones you need help/have a question with.

Which Endpoint/s?

How To Reproduce (If applicable)
Steps to reproduce the behavior:

  1. Request URL / Headers (without credentials) / Body
  2. See error

Screenshots (If applicable)
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Hey @bhavya,

Thank you for reaching out to the Zoom Developer Forum. Please see the top section of our guide on using Chat Bot Tokens where it describes how to use them to make requests to the API.

You may also find the Chat Bot Oauth section of this guide to be helpful:

Let me know if that helps.

Thanks,
Max