Hello,
I’m using Web Meeting SDK, app level is user level. I’m building a web app using the framework React and Node JS. My goal is to be able to schedule Zoom meetings directly from my website.
I’m using OAuth for authentication, so I followed the Zoom OAuth Sample App. I actually tried to run that sample app but I kept getting “500 Internal Server Error” and was not able to find a solution for it. I attempted to do it on my own website anyway, and I got stuck with 2 errors.
I ran the code from the sample app in a local port in the back-end. Code is pretty much the same, but here it is just in case:
app.get('/', (req, res) => {
if (req.query.code) {
let url = 'https://zoom.us/oauth/token?grant_type=authorization_code&code=' + req.query.code + '&redirect_uri=' + process.env.REACT_APP_REDIRECT_URL;
request.post(url, (error, response, body) => {
body = JSON.parse(body);
console.log(`access_token: ${body.access_token}`);
console.log(`refresh_token: ${body.refresh_token}`);
if (body.access_token) {
// Create meeting API goes here
}).auth(process.env.REACT_APP_CLIENT_ID, process.env.REACT_APP_CLIENT_SECRET);
return;
}
res.redirect('https://zoom.us/oauth/authorize?response_type=code&client_id=' + process.env.REACT_APP_CLIENT_ID + '&redirect_uri=' + process.env.REACT_APP_REDIRECT_URL)
})
app.listen(3008, () => console.log(`Zoom app listening at PORT: 3008`))
On the front end, I’m calling this, triggered by clicking a Create Meeting button:
const handleSubmit = (event) => {
event.preventDefault();
console.log(inputs);
const meetingData = {
email: "[my admin zoom email]",
topic: inputs.title,
password: inputs.password,
start_time: inputs.dateTime,
// more options etc
}
try {
console.log("Calling auth API")
axios.get('http://localhost:3008/', meetingData)
.then((response) => {
// Create meeting successful!
}, (error) => {
console.log('Zoom API failed: ' + error.response.data);
});
} catch (error) {
console.log(error);
}
The errors I got:
For the first CORS error, I attempted by setting the headers in my server-side code, just above the get method:
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "http://localhost:3008");
res.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS");
if (req.method == "OPTIONS") {
return res.sendStatus(200);
}
next();
});
Now, there’s still a CORS error, but it’s a slightly different one:
I spent a lot of hours trying to figure them out now, I’m probably missing something completely. If anyone is able to point me to the right direction, that would be very appreciated!