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:
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