I have been trying to convert this node.js script to a comparable version to use as a function in google sheets via google apps script. I have tried to do the conversion by piecing together various bits of code, but I just receive an error any time I try to use the code. I'm planning on using this to generate a signature needed to embed zoom into my website using the SDK at the time of the zoom meeting.
Here is the code below:
const crypto = require('crypto') // crypto comes with Node.js
function generateSignature(apiKey, apiSecret, meetingNumber, role) {
// Prevent time sync issue between client signature generation and Zoom
const timestamp = new Date().getTime() - 30000
const msg = Buffer.from(apiKey + meetingNumber + timestamp + role).toString('base64')
const hash = crypto.createHmac('sha256', apiSecret).update(msg).digest('base64')
const signature = Buffer.from(apiKey, meetingNumber, timestamp, role, hash).toString('base64')
return signature
}
// pass in your Zoom JWT API Key, Zoom JWT API Secret, Zoom Meeting Number, and 0 to join meeting or webinar or 1 to start meeting
console.log(generateSignature(process.env.API_KEY, process.env.API_SECRET, 123456789, 0))
I would really appreciate any insight! Thank you so much in advance!
UPDATE: This code works perfect for Node.js; however, I am trying to convert this to the same functionality within google Apps Script, which is a type of Javascript. One thing I noticed is that Google Apps Script does not support the "const crypto = require('crypto')" function. I'm unsure of how to convert this to receive the same output in Google Apps Script which will be applied to a Google Sheets document
Thank you again for any insight!