Signature invalid in Meeting SDK app type in NextJs

I am trying to upgrade to Meeting SDK app type and have followed the docs and sample app as suggested, however I am getting invalid signature. I have cross-checked everything but not able to figure whats the issue. Here is the code i am using in backend to generate signature

exports.zoomSignature = async (req, res) => {

try {

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_CLIENT_ID,

  mn: req.body.meetingNumber,

  role: req.body.role,

  iat: iat,

  exp: exp,

  appKey:process.env.ZOOM_CLIENT_ID,

  tokenExp: iat + 60 * 60 * 2

}

const sHeader = JSON.stringify(oHeader)

const sPayload = JSON.stringify(oPayload)

const signature = KJUR.jws.JWS.sign('HS256', sHeader, sPayload, process.env.ZOOM_CLIENT_SECRET)



res.json({

  signature: signature

})

} catch (error) {

console.log(error);

return res.status(500).json({

  message: error.message

})

}

}

Here is my frontend code:


  const meetingConfig = {
    sdkKey: "c2t1_GfbR3qrX66FyGsyYQ",
    meetingNumber: meetingNumber,
    userName: name? name : "learner",
    passWord: password,
    leaveUrl,
    role: 0,
    tk: '',
  };
  // console.log(meetingConfig)
  const signatureCall = await apiReq(`${process.env.BASE_URL}/api/session/zoomSignature`, "POST", {
    meetingNumber: meetingNumber,
    role: 0
  });
  const signature = signatureCall.data.signature

  console.log(signature, "SIG")
  ZoomMtg.init({
    leaveUrl: meetingConfig.leaveUrl,
    isSupportAV: true,
    success: () => {
      console.log("SIGNATURE SUCCESS")
      console.log({
        signature: signature,
        meetingNumber: meetingConfig.meetingNumber,
        userName:  meetingConfig.userName,
        sdkKey: meetingConfig.sdkKey,
        userEmail: '',
        passWord: meetingConfig.passWord,
      });
      ZoomMtg.join({
        signature: signature,
        meetingNumber: meetingConfig.meetingNumber,
        userName:  meetingConfig.userName,
        sdkKey: meetingConfig.sdkKey,
        userEmail: '',
        passWord: meetingConfig.passWord,
        success: (success) => {
          console.log(success);
        },
        error: (error) => {
          console.log(error);
        },
      });
    },
    error: (error) => {
      console.log("SIGNATURE ERROR")
      console.log(error);
    },
  });
}

Here is one of the example of an attempt to join meeting from front end with error

Generated signature: {REDACTED}

meetingNumber: ‘81198873582’
sdkKey: ‘c2t1_GfbR3qrX66FyGsyYQ’

Error i get is following
errorCode: 3712
errorMessage: “Signature is invalid.”
method: “join”
result: “Invalid signature.”
status: false

Let me know if any further details required, thanks

your signature seems ok - tested here

is your meeting sdk app created before 11. Feb 2023 ?

if yes, you have to use the SDK Credentials (SDK Key, Secret), not the OAuth credentials (Client ID, Secret)

id

if this is not the problem, you should start with the example on github (CDN version)

the CDN version is ready to use with a few simple steps

CDN/js/index.js:20 var CLIENT_ID = "YOUR_CLIENT_ID_OR_SDK_KEY";;
CDN/js/index.js:26 var CLIENT_SECRET = "YOUR_CLIENT_SECRET_OR_SDK_SECRET;
CDN/js/index.js:112 ... "/meeting.html?" // replace '/' with './'

CDN/js/meeting.js:31 leaveUrl: "/index.html", // replace '/' with './'

Yes it created after 11 Feb, and we are trying to upgrade to Server-to-Server OAuth. I am sure where do i need to put cdn files in my Next.Js. Does it go on _document.js? Is there anyway to fix my current implementation ? I took reference from this sample app GitHub - zoom/meetingsdk-react-sample: Use the Zoom Meeting SDK in React

first test the simple CDN example* - 5 minutes work and you can see if the created Meeting SDK app is working correct

'* it works perfect with localhost without any special server configuration

you have really created a “Meeting SDK App” ?

After running the cdn example as you suggested, it seems i am still getting the same error

Joining meeting timeout.

Signature is invalid.

strange - I have just tested the CDN example with my (old) Meeting SDK app and my “test meeting” → no problems

next ideas

  • is there a “retry” button on your error message ? if yes click it multiple times

  • is the time correctly synchronized on your computer?

  • create a meeting with settings (like my test meeting) and connect as attendee

It seems like my colleague miscommunicated, it seems he has created only o-auth app and not meeting sdk. My apologies, we were using JWT app and are now trying to upgrade to server to server o-auth as JWT app is being depricated. I assume creating Meeting SDK app is necessary for this to work?

good news - the error is found :slight_smile:

Yes i will update here after creating it and if it works afterwards :slight_smile:

Update: I created SDK app and replaced its sdk key and secret to frontend and backend where i am generating signature. Unfortunately i am still getting invalid signature. Tried both CDN and React integration. Here is the new signature that was generated:

[REDACTED]

Also for testing i created a new zoom account and created new sdk app on it and used that credentials on CDN, still invalid signature. Strange

Hey @varcityzoom1 ,

Can you try using this sample app to generate the signature?

Make sure to pass in your Meeting SDK app type Client ID and Client Secret:

If that still does not work, please submit a devsupport ticket and ask the support team to check if the Meeting SDK is enabled for your account.

Best,
Tommy

I used the sample app to generate following singature:

[REDACTED]

on decoding it has the following payload:
{
“sdkKey”: “lAzXXLSJQyKbYI1xZwqQOw”,
“mn”: “82295245018”,
“role”: 0,
“iat”: 1681189069,
“exp”: 1681196269,
“appKey”: “lAzXXLSJQyKbYI1xZwqQOw”,
“tokenExp”: 1681196269
}

and my sdk app client id is " lAzXXLSJQyKbYI1xZwqQOw" so it looks fine. Still I am getting

  1. errorCode: 3712
  2. errorMessage: “Signature is invalid.”
  3. method: “join”
  4. result: “Invalid signature.”
  5. status: false

So, not sure why it is even when i am doing all steps correctly

One more additional info, i already had a sdk app type created before feb, but its being depricated so i have created new one and tested using new app’s credentials

Same issue with CDN

is you meeting app active?

in my working (free) account with a “new” Meeting SDK is looks

you don’t use “localhost” ? I did’t know that file protocoll is working - I have never tested it

UPDATE: just testet - file-protocoll work also for me

Update: it work after retrying 4-5 times in cdn

perhaps you have a problem with the local time on your computer - if it’s some seconds wrong, such errors can happen

1 Like