Issue getting signature key - Error: mac key shall be specified for HS* alg

Description
I followed:

Did exactly as was said, and whenever I make a post with postman with the role, and mettingID I get the error below.

Console Error
The full error message or issue you are running into.

Zoom Web Meeting SDK Sample Signature Node.js on port 4000!
{
  sdkKey: undefined,
  mn: undefined,
  role: undefined,
  iat: 1677200602,
  exp: 1677207802,
  appKey: undefined,
  tokenExp: 1677207802
}
mac key shall be specified for HS* alg

Which Web Meeting SDK version?
Latest

Meeting SDK Code Snippets
The code snippets that are causing the error / issue so we can reproduce.

require('dotenv').config()
const express = require('express')
const bodyParser = require('body-parser')
const crypto = require('crypto')
const cors = require('cors')
const KJUR = require('jsrsasign')

const app = express()
const port = process.env.PORT || 4000


app.use(bodyParser.json(), cors())
app.options('*', cors())

app.post('/', (req, res) => {
  const iat = Math.round(new Date().getTime() / 1000) - 30;
  const exp = iat + 60 * 60 * 2
  const oHeader = { alg: 'HS256', typ: 'JWT' }
  const oPayload = {
    sdkKey: process.env.ZOOM_SDK_KEY,
    mn: req.body.meetingNumber,
    role: req.body.role,
    iat: iat,
    exp: exp,
    appKey: process.env.ZOOM_SDK_KEY,
    tokenExp: iat + 60 * 60 * 2
  }
  console.log(oPayload)

  const sHeader = JSON.stringify(oHeader)
  const sPayload = JSON.stringify(oPayload)
  const signature = KJUR.jws.JWS.sign('HS256', sHeader, sPayload, process.env.ZOOM_SDK_SECRET)

  res.json({
    signature: signature
  })
})

app.listen(port, () => console.log(`Zoom Meeting SDK Sample Signature Node.js on port ${port}!`))

To Reproduce(If applicable)
Steps to reproduce the behavior:

  1. npm install
  2. npm run start
  3. Make post with postman
  4. See error

Device (please complete the following information):

  • Device: [Windows 10 PC]
  • Browser: [e.g. Chrome]

lol… resolved after I posted this I’ll leave it up just in-case other people have the issue…

Resolved by:
Moving .env file into same folder as the js.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.