# Signature invalid

**URL:** <https://devforum.zoom.us/t/signature-invalid/91687>\
**Category:** Web\
**Created:** [July 12, 2023, 1:42pm UTC](https://devforum.zoom.us/t/signature-invalid/91687 "2023-07-12T13:42:36Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![c.egeolu](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@c.egeolu](https://devforum.zoom.us/u/c.egeolu)\
**Post date:** [July 12, 2023, 1:42pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/1 "2023-07-12T13:42:36Z")

</div>

Please kindly assist. Each time we want to join meeting when using the web sdk we always receive Signature Invalid.

kindly guide me on how to resolve the issue.

---

<div class="post-metadata">

**Author:** ![dnna](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dnna/32/36399_2.png) [@dnna](https://devforum.zoom.us/u/dnna)\
**Post date:** [July 12, 2023, 1:55pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/2 "2023-07-12T13:55:43Z")

</div>

Are you using the component view or client view SDK? Can you provide some more info about how you are generating the signature and what you are passing in the join function call?

---

<div class="post-metadata">

**Author:** ![c.egeolu](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@c.egeolu](https://devforum.zoom.us/u/c.egeolu)\
**Post date:** [July 12, 2023, 2:11pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/3 "2023-07-12T14:11:39Z")

</div>

var signature = ZoomMtg.generateSDKSignature({  
meetingNumber: meetingConfig.mn,  
sdkKey: CLIENT\_ID,  
sdkSecret: CLIENT\_SECRET,  
role: meetingConfig.role,  
success: function (res) {

```
                        meetingConfig.signature = res.result;
                        meetingConfig.sdkKey = CLIENT_ID;
                        var joinUrl = "/zoom/meeting.html?" + testTool.serialize(meetingConfig);
                       
                    window.open(joinUrl, "_blank");

                       
                    },
                });

```

i am using component view (Web View)

---

<div class="post-metadata">

**Author:** ![dnna](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dnna/32/36399_2.png) [@dnna](https://devforum.zoom.us/u/dnna)\
**Post date:** [July 12, 2023, 3:58pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/4 "2023-07-12T15:58:32Z")

</div>

In my implementation, I used the following function to generate the working signature:

```auto
function generateSignature(apiKey, apiSecret, meetingNumber, role) {
  const iat = Math.round(new Date().getTime() / 1000) - 30;
  const exp = iat + 60 * 60 * 2;
  const oHeader = { alg: "HS256", typ: "JWT" };

  const oPayload = {
    sdkKey: apiKey,
    appKey: apiKey,
    mn: meetingNumber,
    role: role,
    iat: iat,
    exp: exp,
    tokenExp: exp,
  };

  const sHeader = JSON.stringify(oHeader);
  const sPayload = JSON.stringify(oPayload);
  return KJUR.jws.JWS.sign("HS256", sHeader, sPayload, apiSecret);
}

```

And the `ZoomMtg.join` call looks like this:

```auto
const signature = generateSignature(
        ZOOM_SDK_KEY,
        ZOOM_SDK_SECRET,
        meetingId,
        0
);
ZoomMtg.join({
  sdkKey: ZOOM_SDK_KEY,
  signature,
  meetingNumber: meetingId,
  passWord: meetingPassword ?? null,
  userName: "Test user",
  userEmail: "test@example.com",
  zak: null,
    success: (success) => {
       console.log(success);
    }
});

```

As long as the ZOOM\_SDK\_KEY, ZOOM\_SDK\_SECRET, meetingId and meetingPassword are correct it should connect.

---

<div class="post-metadata">

**Author:** ![c.egeolu](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@c.egeolu](https://devforum.zoom.us/u/c.egeolu)\
**Post date:** [July 12, 2023, 5:22pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/5 "2023-07-12T17:22:19Z")

</div>

Thanks for the code.

Does your code also prevent “The Signature has expired” error and suddenly the meeting ends

---

<div class="post-metadata">

**Author:** ![dnna](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dnna/32/36399_2.png) [@dnna](https://devforum.zoom.us/u/dnna)\
**Post date:** [July 12, 2023, 8:24pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/6 "2023-07-12T20:24:27Z")

</div>

Haven’t seen that in my case, but note this line in the code:  
`const iat = Math.round(new Date().getTime() / 1000) - 30;`  
is based on the current time of the computer or server the code is running on. Is it possible the time is not correct and so when it reaches Zoom servers it shows the signature as expired?

---

<div class="post-metadata">

**Author:** ![csepiyush](https://avatars.discourse-cdn.com/v4/letter/c/a4c791/32.png) [@csepiyush](https://devforum.zoom.us/u/csepiyush)\
**Post date:** [July 12, 2023, 9:02pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/7 "2023-07-12T21:02:00Z")

</div>

`AccessDenied`Access DeniedK7FW65NSZJ4AY7ZKLXH6y9y/gpRtuEZcGX7Eh8tkUx8JKmBJEZMxEqWhTZO2rGL3SWmDRlnW3YLJtcwOoUklnDJNemg=  
pre load wasm success: [//source.zoom.us/2.14.0/lib/av/1503\_audio.encode.wasm](https://source.zoom.us/2.14.0/lib/av/1503_audio.encode.wasm)

Join meeting error: {method: ‘join’, status: false, result: ‘Invalid signature.’, errorMessage: ‘Signature is invalid.’, errorCode: 3712}

---

<div class="post-metadata">

**Author:** ![c.egeolu](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@c.egeolu](https://devforum.zoom.us/u/c.egeolu)\
**Post date:** [July 13, 2023, 12:25pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/8 "2023-07-13T12:25:13Z")

</div>

please explain in details: const iat = Math.round(new Date().getTime() / 1000) - 30;

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [July 13, 2023, 7:02pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/9 "2023-07-13T19:02:58Z")

</div>

Hi @c.egeolu , here is more details about math.round potential issue:

> [@Randomly getting "Signature is invalid" error](https://devforum.zoom.us/t/randomly-getting-signature-is-invalid-error/77667/2):
>
> Found that Math.round() returning a timestamp which is randomly 10-30sec more with actual value. After removing it, things started working fine.

---

<div class="post-metadata">

**Author:** ![dnna](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dnna/32/36399_2.png) [@dnna](https://devforum.zoom.us/u/dnna)\
**Post date:** [July 15, 2023, 11:23am UTC](https://devforum.zoom.us/t/signature-invalid/91687/11 "2023-07-15T11:23:08Z")

</div>

@c.egeolu The signature attribute is based on JSON Web Tokens. In JWT, the iat attribute indicates when the token was issued (which in my implementation was the current timestamp minus 30 seconds to avoid issues with round, like the one @gianni.zoom posted).

Based on iat, the exp attribute is calculated, which is when the token expires.

You can see more info about these two attributes here [JSON Web Token Claims](https://auth0.com/docs/secure/tokens/json-web-tokens/json-web-token-claims#registered-claims)

---

<div class="post-metadata">

**Author:** ![c.egeolu](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@c.egeolu](https://devforum.zoom.us/u/c.egeolu)\
**Post date:** [July 19, 2023, 6:38pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/12 "2023-07-19T18:38:52Z")

</div>

Can you please share a complete working sample code using javascript to generate the signature without using JWT and removing the using Math.round()

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [July 19, 2023, 7:57pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/13 "2023-07-19T19:57:44Z")

</div>

Hi @c.egeolu ,

You need the JWT to generate the signature, but please see the attached code sample on our postman workspace:

[https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/request/22097587-177f9fb7-6824-41fa-8de6-3b1971ca70fc](https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/request/22097587-177f9fb7-6824-41fa-8de6-3b1971ca70fc)

---

<div class="post-metadata">

**Author:** ![c.egeolu](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@c.egeolu](https://devforum.zoom.us/u/c.egeolu)\
**Post date:** [July 19, 2023, 10:34pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/14 "2023-07-19T22:34:49Z")

</div>

Thanks for your prompt response.

This is the function i used to generate the signature

function generateZoomSignaturecustom(meetingNumber, apiKey, apiSecret, role, timestamp)

{  
// Concatenate the required information  
var signature = apiKey + meetingNumber + timestamp + role;

```
        // Generate a hash using the API Secret and concatenate it with the signature
        var hash = CryptoJS.HmacSHA256(signature, apiSecret).toString(CryptoJS.enc.Base64);
        var signature = apiKey + "." + meetingNumber + "." + timestamp + "." + role + "." + hash;

        // Return the generated signature
        return signature;
    }

```

// i called the above function  
var signature2 = generateZoomSignaturecustom(meetingNumber, apikey, SECRETkey, 0, Math.round(new Date().getTime() / 1000));

can this also help?

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [July 20, 2023, 1:18pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/15 "2023-07-20T13:18:48Z")

</div>

Hi @c.egeolu ,

Did you test the value you received to check if it works?

---

<div class="post-metadata">

**Author:** ![c.egeolu](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@c.egeolu](https://devforum.zoom.us/u/c.egeolu)\
**Post date:** [July 20, 2023, 1:24pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/16 "2023-07-20T13:24:31Z")

</div>

I got Signature invalid for some system while others were able to connect.

I have about 30 people connecting simultaneously. Some could connect while others were having Signature invalid.

Below is the new function to connect

function generateZoomJWT(apiKey, apiSecret, meetingNumber, role) {

```
return new Promise((resolve, reject) => {

const iat = (new Date().getTime()-30000)/1000;
const exp = iat + 60 * 60 * 2
const oHeader = { alg: 'HS256', typ: 'JWT' }

const oPayload = {
    sdkKey: apiKey,
    appKey: apiKey,
    mn: meetingNumber,
    role: 0,
    iat: iat,
    exp: exp,
    tokenExp: exp
}

const sHeader = JSON.stringify(oHeader)
const sPayload = JSON.stringify(oPayload)
const sdkJWT = KJUR.jws.JWS.sign('HS256', sHeader, sPayload, apiSecret)
   resolve(sdkJWT)
     });

```

}

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [July 25, 2023, 2:08pm UTC](https://devforum.zoom.us/t/signature-invalid/91687/17 "2023-07-25T14:08:03Z")

</div>

Hi @c.egeolu ,

You may be running into a similar issue outlined here:

> [@Signature invalid](https://devforum.zoom.us/t/signature-invalid/91687/6):
>
> Haven’t seen that in my case, but note this line in the code: const iat = Math.round(new Date().getTime() / 1000) - 30; is based on the current time of the computer or server the code is running on. Is it possible the time is not correct and so when it reaches Zoom servers it shows the signature as expired?

Please use this script to create your signature:

> [@Signature invalid](https://devforum.zoom.us/t/signature-invalid/91687/13):
>
> Hi @c.egeolu , You need the JWT to generate the signature, but please see the attached code sample on our postman workspace: [https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/request/22097587-177f9fb7-6824-41fa-8de6-3b1971ca70fc](https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/request/22097587-177f9fb7-6824-41fa-8de6-3b1971ca70fc)

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [August 25, 2023, 12:08am UTC](https://devforum.zoom.us/t/signature-invalid/91687/18 "2023-08-25T00:08:39Z")

</div>

Closed on August 25, 2023, 12:08am UTC

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