将node.js转换为Google Sheeph apps脚本格式(JavaScript)for Zoom SDK签名创建

发布于 2025-02-12 06:42:11 字数 1180 浏览 1 评论 0原文

我一直在尝试通过Google Apps脚本将此node.js脚本转换为可比较的版本,以用作Google表中的功能。我试图通过将各种代码拼凑在一起来进行转换,但是每当我尝试使用代码时,我只是收到错误。我计划在变焦会议时使用它来生成一个使用SDK嵌入我网站所需的签名。

这是以下代码:

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))

我真的很感谢任何见解!非常感谢您!

更新:此代码非常适合Node.js;但是,我试图将其转换为Google Apps脚本中的相同功能,这是一种JavaScript。我注意到的一件事是,Google Apps脚本不支持“ const crypto = require('crypto')”功能。我不确定如何将其转换为在Google Apps脚本中接收相同的输出,该输出将应用于Google Sheeps文档,

谢谢您的任何见解!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文