I am trying to make a zoom oauth2.0 app. In order to do so, I am making a backend route that accesses the zoom api. I am trying to follow steps 1 and 2 located https://marketplace.zoom.us/docs/guides/auth/oauth, but I am having trouble with step 2, which is the post request to get the token. Here is my code:
router.get('/zoom', auth, async (req, res) => {
if (req.query.code) {
const url = `https://zoom.us/oauth/token?grant_type=authorization_code&code=${req.query.code}&redirect_uri=${CLIENT_HOME_PAGE_URL}`;
const headers = {
'Content-Type': 'application/json',
Authorization:
'Basic clientid:clientsecret'
};
try {
const res = await axios.post(url, null, { headers: headers });
console.log(res);
} catch (err) {
console.error(err.message);
return res.status(500).send('Sever Error');
}
}
res.redirect(
`https://zoom.us/oauth/authorize?response_type=code&client_id=${ZOOM_CLIENT_ID}&redirect_uri=${ZOOM_REDIRECT_URI}`
);
});
At this point, I simply want to print the data. ZOOM_REDIRECT_URI
points to the same route of '/zoom'
and clientid:clientsecret
is replaced with the base64string version of the actual client id and secret. I am able to be redirected to https://zoom.us/oauth/authorize which redirects me back to /zoom
and tries to make a post request to the url, but the post request fails with status 403. What is wrong with my code?