Signature is invalid - 3712

i am getting this error -

{
    "type": "JOIN_MEETING_FAILED",
    "reason": "Signature is invalid.",
    "errorCode": 3712
}

this is the code to generate signature

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_MEETING_SDK_KEY,
       mn: req.body.meetingNumber,
      role: 0,
      iat: iat,
      exp: exp,
      tokenExp: iat + 60 * 60 * 2,
    };

    const sHeader = JSON.stringify(oHeader);
    const sPayload = JSON.stringify(oPayload);
    console.log({ sHeader, sPayload });

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

    res.json({ data: signature });

Hi @qwerty1234 , which version of Web MSDK?

Please look at these two suggestions:

Signature is invalid.', errorCode: 3712 - #4 by chunsiong.zoom

i am using

"@zoom/meetingsdk": "^3.1.4",

 "react": "^18.2.0",
useEffect(() => {
    const client = ZoomMtgEmbedded.createClient();

    if (signatureFetched && signature) {
      const meetingSDKElement = document.getElementById("meetingSDKElement");

      if (meetingSDKElement) {
        client.init({ zoomAppRoot: meetingSDKElement, language: "en-US" });
        client.join({
          sdkKey: sdkKey,
          signature: signature,
          meetingNumber: meetingNumber,
          password: password,
          userName: userName,
        });
      }
    }
  }, [signature, signatureFetched]);

I am using component view

 <div>
      <div id="meetingSDKElement"></div>
      <Button onClick={getSignature}>Join Meeting</Button>
    </div>

Hi @qwerty1234 ,

If your app credentials do you see client id and client secret or sdk key/secret?

Additionally can you reproduce with the sample app? Zoom Meeting SDK for web