hello @vic.yang
Having issue on the MEETING SDK got an error
Error creating meeting: { code: 124, message: ‘Invalid access token.’ }
im trying to create a meeting and getting the meeting id
here is my code
app.post('/createMeeting', async (req, res) => {
try {
const zoomToken = generateZoomToken(); // Generate the token once
console.log("teroro", zoomToken);
const response = await axios.post('https://api.zoom.us/v2/users/me/meetings', {
topic: 'test',
type: 1 // 1 for instant meeting, you can customize it according to your needs
}, {
headers: {
'Authorization': `Bearer ${zoomToken}`
}
});
console.log("awaaa ",response.data)
res.json(response.data);
} catch (error) {
console.error('Error creating meeting:', error.response ? error.response.data : error.message);
res.status(error.response ? error.response.status : 500).json({ error: 'Failed to create meeting' });
}
});
function generateZoomToken() {
const iat = Math.round(new Date().getTime() / 1000) - 30;
const exp = iat + 60 * 60 * 2
const oHeader = { alg: 'HS256', typ: 'JWT' }
const oPayload = {
sdkKey: API_KEY,
role: 1,
iat: iat,
exp: exp,
appKey: API_KEY,
tokenExp: iat + 60 * 60 * 2
}
const sHeader = JSON.stringify(oHeader)
const sPayload = JSON.stringify(oPayload)
const signature = KJUR.jws.JWS.sign('HS256', sHeader, sPayload, API_SECRET)
return signature
}
i am a developer of the account and not the owner