Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Zoom Webinar Lambda. Register Person for webinar programatically
const jwt = require('jsonwebtoken')
const serverless = require('serverless-http')
const express = require('express')
const axios = require('axios')
const cors = require('cors')
const app = express()
app.use(express.json())
app.use(cors())
app.post('/zoom', function (req, res) {
const payload = {
iss: process.env.ZOOM_API_KEY,
exp: ((new Date()).getTime() + 5000)
}
const token = jwt.sign(payload, process.env.ZOOM_API_SECRET)
const userToRegister = {
email: req.body.email,
first_name: req.body.firstName,
last_name: req.body.lastName,
org: req.body.organisation
}
// Make a request for a user with a given ID
axios.post(`https://api.zoom.us/v2/webinars/${req.body.webinarID}/registrants`, userToRegister, {
headers: {
'Authorization': `Bearer ${token}`
}
})
.then(function (response) {
// handle success
res.json(response.data)
})
.catch(function (error) {
// handle error
console.error(error)
res.status(500).json({error})
})
})
module.exports.webinar = serverless(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment