# Zoom Meeting SDK Signature Creation

**URL:** <https://devforum.zoom.us/t/zoom-meeting-sdk-signature-creation/91781>\
**Category:** Meeting SDK\
**Created:** [July 13, 2023, 5:10pm UTC](https://devforum.zoom.us/t/zoom-meeting-sdk-signature-creation/91781 "2023-07-13T17:10:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ritesh.kumar](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@ritesh.kumar](https://devforum.zoom.us/u/ritesh.kumar)\
**Post date:** [July 13, 2023, 5:10pm UTC](https://devforum.zoom.us/t/zoom-meeting-sdk-signature-creation/91781/1 "2023-07-13T17:10:03Z")

</div>

**Description**  
I am Creating Signature From my Java Spring Boot Application but one in a 10-20 times it says Signature is Invalid rest of the times it works fine. Don’t Know the Reason.

**Browser Console Error**  
tp-errors.handler.ts:31 Error intercepted Error: Uncaught (in promise): Object: {“type”:“JOIN\_MEETING\_FAILED”,“reason”:“Signature is invalid.”,“errorCode”:3712}  
at resolvePromise (zone.js:1211:1)  
at resolvePromise (zone.js:1165:1)  
at zone.js:1118:1  
at zone.js:1134:1  
at asyncGeneratorStep (asyncToGenerator.js:11:1)  
at \_throw (asyncToGenerator.js:29:1)  
at \_ZoneDelegate.invoke (zone.js:372:1)  
at Object.onInvoke (core.mjs:25608:33)  
at \_ZoneDelegate.invoke (zone.js:371:1)  
at Zone.run (zone.js:134:1)  
h

**Which Web Meeting SDK version?**  
“^2.9.5”

**Meeting SDK Signature Generation Code Snippet**

```auto
 public String getZoomSignature() {
    String sdkKey = " **********";
    String sdkSecret =" *********";
    if (sdkKey == null || sdkSecret == null) {
      return null;
    } else {
      long iat = Math.round(new Date().getTime() / (float) 1000) - 30;
      long exp = iat + 60 * 60 * 2;

      JSONObject header = new JSONObject();
      header.put("alg", "HS256");
      header.put("typ", "JWT");

      JSONObject payload = new JSONObject();
      payload.put("sdkKey", sdkKey);
      payload.put("mn", id);
      payload.put("role", 0);
      payload.put("iat", iat);
      payload.put("exp", exp);
      payload.put("appKey", sdkKey);
      payload.put("tokenExp", exp);

      final String base64Payload = encode(payload.toString().getBytes(StandardCharsets.UTF_8));
      final String base64header = encode(header.toString().getBytes(StandardCharsets.UTF_8));
      final String signature = hmacSha256(base64header + "." + base64Payload, sdkSecret);

      return base64header + "." + base64Payload + "." + signature;
    }
  }

  public String hmacSha256(String data, String secret) {
    try {
      byte[] hash = secret.getBytes(StandardCharsets.UTF_8);
      Mac sha256Hmac = Mac.getInstance("HmacSHA256");
      SecretKeySpec secretKey = new SecretKeySpec(hash, "HmacSHA256");
      sha256Hmac.init(secretKey);
      byte[] signedBytes = sha256Hmac.doFinal(data.getBytes(StandardCharsets.UTF_8));
      return encode(signedBytes);
    } catch (NoSuchAlgorithmException | InvalidKeyException ex) {
      LOGGER.debug("Error in Zoom Signature Creation \n" + ex.getMessage());
    }
    return null;
  }

  public String encode(byte[] bytes) {
    return Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);
  }

```

**Device (please complete the following information):**

- Device: [Macbook Pro, windows]
- OS: [e.g. macOS Ventura, windows 11]
- Browser: [e.g. Chrome]
- Browser Version [e.g. 88.0.4324.150 (Official Build) (x86\_64)]

---

<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, 6:58pm UTC](https://devforum.zoom.us/t/zoom-meeting-sdk-signature-creation/91781/2 "2023-07-13T18:58:50Z")

</div>

Hi @ritesh.kumar ,

Sounds like it could be this:

> [@Randomly getting "Signature is invalid" error](https://devforum.zoom.us/t/randomly-getting-signature-is-invalid-error/77667):
>
> Meeting SDK Type and Version @zoomus/websdk: 2.8.0 Type: Component View Description Randomly getting “Signature is invalid” error while joining zoom meeting. But when I retries to join zoom meeting with same signature then after some retries or some time I can able to join with the same signature. I am generating signature at the server side with role = 0. Error? {type: ‘JOIN\_MEETING\_FAILED’, reason: ‘Signature is invalid.’, errorCode: 3712} Following is the signature generation code sni…

Please read through that thread and let me know if you’re able to adjust and fix the issue!
