Hello @elisa.zoom,
Sorry for the late reply. So, in my flow, I have it like this:
- User signs into their account
- Once logged in, they will be able to go in and go to their Zoom settings
- Once on Zoom settings, they will be able to click an “Authorize” button, that will essentially be used to redirect a user to the OAuth flow
- When it comes back, we get the authorization code, which immediately will be used to get the access_token and refresh_token. At this point, we save that into our Database.
I think I might be doing a wrong step somewhere, because when I use postman, I am able to use the access token normally, but when I use the access token generated by my server, it gives me the error above. Here is the function I have to get the token:
router.post("/authorize/access", userAuth, (req, res) => {
const { zoom_auth_code, zoom_comparative } = req.body;
// Get user ID from auth token to compare vs zoom comparative id
const user_id = req.payload.subject;
if (user_id != zoom_comparative) {
res.status(401).json({ message: "Comparative ID does not match" });
return;
}
const APIURL = "https://zoom.us/oauth/token";
axios({
method: "post",
url: APIURL,
params: {
code: zoom_auth_code,
grant_type: "authorization_code",
redirect_uri: "https://dashboard.bizzll.com/account/zoom-settings",
},
headers: {
Authorization: `Basic <base64 client_id:client_secret>`,
"Content-Type": "application/x-www-form-urlencoded",
},
})
.then((response) => {
console.log(response);
ZoomModel.addZoomAccessCode(
user_id,
response.data.access_token,
response.data.refresh_token
)
.then((response) => {
res.status(201).json(response);
})
.catch((err) => {
res
.status(500)
.json({ message: "Error adding access token", error: err });
});
})
.catch((err) => {
console.log(err.response);
res
.status(500)
.json({ message: "Error getting access token", error: err });
});
});
That function does give me a valid access token, but for some reason, I get the error:
{ code: 124, message: ‘Invalid access token.’ }
Again, if I use the OAuth flow via Postman, it works well, but if I use the access token used from my flow, it gives me the error above.