Skip to content

Instantly share code, notes, and snippets.

@ifsd

ifsd/zoom.js Secret

Created June 30, 2021 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifsd/60d65218c1b5eab6b9f1ecc99360d30d to your computer and use it in GitHub Desktop.
Save ifsd/60d65218c1b5eab6b9f1ecc99360d30d to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const axios = require('axios');
const ZOOM_CLIENT_ID = 'my_client_id'; // I'm using the right ones in my code
const ZOOM_CLIENT_SECRET = 'my_client_secret';
const ZOOM_CALLBACK_URI = 'http://localhost:4000/oauth-callback';
const PORT = 4000;
app.get('/', (req, res) => {
res.redirect(`https://zoom.us/oauth/authorize?response_type=code&client_id=${ZOOM_CLIENT_ID}&redirect_uri=${ZOOM_CALLBACK_URI}
`);
});
app.get('/oauth-callback', async (req, res) => {
const b64 = Buffer.from(`${ZOOM_CLIENT_ID}:${ZOOM_CLIENT_SECRET}`).toString(
'base64'
);
const opts = {
headers: {
'content-type': 'application/x-www-form-urlencoded',
Authorization: 'Basic ' + b64,
},
params: {
code: req.query.code,
grant_type: 'authorization_code',
redirect_uri: 'http://localhost:4000/oauth-callback',
},
};
try {
const { data } = await axios.post(
`https://zoom.us/oauth/token`,
null,
opts
);
console.log(data);
const config = {
headers: {
Authorization: 'Bearer ' + data.access_token,
},
};
const token = data.access_token;
const response = await axios.get(
'https://api.zoom.us/v2/metrics/meetings/3560826516/participants',
config
);
res.json(response.data);
} catch (error) {
console.log(error);
res.status(error.response.status).json({ message: error.message });
}
});
app.listen(PORT, () => {
console.log(`app launched on port ${PORT} :)`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment