# Generating signatures server side for the web sdk with node.js

**URL:** <https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609>\
**Category:** Web\
**Created:** [November 28, 2018, 7:22am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609 "2018-11-28T07:22:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [November 28, 2018, 7:22am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/1 "2018-11-28T07:22:21Z")

</div>

So the docs show how to generate signatures server side only with PHP. Not sure how to do the same with nodejs. Can someone post an example?

Cheers!

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [November 28, 2018, 8:53am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/2 "2018-11-28T08:53:31Z")

</div>

Hello @shahar and thanks for asking a valuable question.

I’d be happy to provide an answer, but I am unable to locate the specific documentation (containing the PHP code) to which you’re referring. Please accept my apologies, we’ve been moving fast and migrating our docs to more flexible systems, but that means we have some fragmentation and perhaps duplication of content on multiple URLs.

I tried searching our current [Developer Documentation](https://marketplace.zoom.us/docs) for `signature`, but couldn’t find a PHP example.

Would you share the URL for the docs to which you are referring to specifically please?

Thanks,  
Ben

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [November 28, 2018, 10:09am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/3 "2018-11-28T10:09:20Z")

</div>

Hi Ben,

It’s here: [https://zoom.github.io/zoom-sdk-web/global.html#generate\_signature](https://zoom.github.io/zoom-sdk-web/global.html#generate_signature)

Here’s a screen shot:

 ![zoom](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/1X/41e457f1dfef6e76985230a61af6af93c409bd16.png)

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [November 28, 2018, 2:39pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/4 "2018-11-28T14:39:43Z")

</div>

Thanks for that @shahar

I haven’t tested any of this code, so there are likely bugs, but I have created this Node.js module which you can require from within your app code and use to generate the signature hash as required by those docs.

> <https://gist.github.com/bdeanindy/ed711a1e573eacbcb9c231242f0d53ad>

You would use it as follows:

```
const zoomUtil = require(`<relative_path_to_where_you_save_this_module.js`);
let myMeetingNumber = 12345; // replace this with a real meeting number
let myParticipantRole = 0; // to make myself participant, but default is 1 for host
let mySignature = zoomUtil.generateSignatureString(myMeetingNumber, myParticipantRole);
// now, mySignature should be valid and ready to use

```

I hope this helps, let me know if you run into issues with this at all.

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [November 28, 2018, 7:28pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/5 "2018-11-28T19:28:39Z")

</div>

Hi @bdeanindy

I really appreciate your effort and timely response, however it doesn’t work… I fixed some tiny errors myself, but still it doesn’t provide a correct signature…  
Can you test it with actual api\_key, api\_secret and meeting\_number and see that you get a vaild signature?

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [November 28, 2018, 7:34pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/6 "2018-11-28T19:34:04Z")

</div>

You know, you have this code working in webim.js, it is just minimised and obfuscated so I can’t really figure it out, but I’m pretty sure you can get access to the source code, and be able to port it.

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [November 28, 2018, 9:50pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/7 "2018-11-28T21:50:11Z")

</div>

What is the specific error response you’re receiving please?

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [November 28, 2018, 9:56pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/8 "2018-11-28T21:56:08Z")

</div>

@bdeanindy Permission denied

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [November 28, 2018, 10:24pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/9 "2018-11-28T22:24:15Z")

</div>

Which keys are you using please?  
API or SDK keys?

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [November 28, 2018, 11:10pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/10 "2018-11-28T23:10:58Z")

</div>

Here is the second version of this app’s code (wow! my v1 was HIDEOUSLY BAD…LOL).  
Anyway, this is all cleaned up.  
Just:

1. Unzip
2. Rename `env.tmpl` --\> `.env`
3. Update the values in `.env` with your values (make sure to use the SDK Keys, NOT the API Keys).
4. Write/Save/Close files
5. `node index.js`

There’s your signature, and I just tested from scratch with a meeting and it worked just fine.  
Let me know if you hit any snags and hope this helps!

[https://drive.google.com/file/d/15BBZ79DAA0ljtEvHm-E38Ox6IVJxpZwB/view?usp=sharing](https://drive.google.com/file/d/15BBZ79DAA0ljtEvHm-E38Ox6IVJxpZwB/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [November 29, 2018, 6:59am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/11 "2018-11-29T06:59:11Z")

</div>

Didn’t know there was a different set of SDK key+secret…

Anyway, when I run it with the SDK key+secret set, I get the message: “The api key is wrong.”  
When I run it with the API key+secret, I get “Invalid signature”.

All that said, when I run the [sample-app-web](https://github.com/zoom/sample-app-web) I run it with the API key+secret and it works, not with the SDK set.

Also, the length of the signature generated by the sample-app-web (it prints it to the console) is much shorter than the one your module generates.

---

<div class="post-metadata">

**Author:** ![michael\_p.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_p.zoom/32/18105_2.png) [@michael\_p.zoom](https://devforum.zoom.us/u/michael_p.zoom)\
**Post date:** [November 29, 2018, 2:12pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/12 "2018-11-29T14:12:38Z")

</div>

@shahar,

For your invalid signature error, what Role to do you have it set to, 1 or 0?

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [November 29, 2018, 4:02pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/13 "2018-11-29T16:02:03Z")

</div>

@bdeanindy I use 0 for role.

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [November 29, 2018, 7:31pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/14 "2018-11-29T19:31:49Z")

</div>

@shahar  
The SDK uses completely different API than our REST APi. Thus the different Key Sets.

I am busy handling an escalation, and the code I’ve provided worked for me/gets you moving in the right direction.

Could you spend some time working with this code to get it working for yourself and share what you’ve learned here for others (and to me…so I can see what you needed to get things working for yourself)?

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [December 3, 2018, 7:40am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/15 "2018-12-03T07:40:27Z")

</div>

OK I spent much time and to no avail. Am I the only one in the world trying to generate signature server side in nodejs? It’s so frustrating, you HAVE the code working in [https://source.zoom.us/zoom-meeting-1.3.5.min.js](https://source.zoom.us/zoom-meeting-1.3.5.min.js) it is just so obscured and minified I can’t make much of it. You have access to the source, can’t you simply port it???  
On top of it, I am a PAYING customer to zoom, can’t I have this thing sorted out?

Here’s the best unobfuscated version of the code that I can see

 ![25%20AM](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/1X/a427044d03382b4f0ac6873a0dbdd52aba9102ee.png)

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [December 3, 2018, 11:41pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/16 "2018-12-03T23:41:54Z")

</div>

Hey @shahar  
We understand your frustration, appreciate your business, and are trying to help.

Debugging code remotely is a challenging situation for everyone involved.

I will revisit my code to perform some additional tests.

What version of Node.js are you running please?

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [December 4, 2018, 2:34am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/17 "2018-12-04T02:34:52Z")

</div>

Try this out (that’s from the source).

```
import * as base64JS from 'js-base64';
import * as hmacSha256 from 'crypto-js/hmac-sha256';
import * as encBase64 from 'crypto-js/enc-base64';function generateSignature(data) {
    let signature = '';
    const ts = new Date().getTime();
    try {
        const msg = base64JS.Base64.encode(data.apiKey + data.meetingNumber + ts + data.role);
        const hash = hmacSha256.default(msg, data.apiSecret);
        signature = base64JS.Base64.encodeURI(`${data.apiKey}.${data.meetingNumber}.${ts}.${data.role}.${encBase64.stringify(hash)}`);
    } catch (e) {
         console.log('error')
    }
    return signature;
}
```

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [December 4, 2018, 7:36am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/18 "2018-12-04T07:36:40Z")

</div>

@bdeanindy Praise you and the lord it works!!!  
That’s all I needed!  
btw, it works with the API key/secret set and NOT with the sdk set.

---

<div class="post-metadata">

**Author:** ![shahar](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@shahar](https://devforum.zoom.us/u/shahar)\
**Post date:** [December 4, 2018, 7:47am UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/19 "2018-12-04T07:47:34Z")

</div>

@bdeanindy now the only thing that bothers me is that the embedded zoom works ONLY if i have /lib and /lib/av paths in my website, this is soooooo amateur to enforce me to have that, I want to put my resources on a CDN!

---

<div class="post-metadata">

**Author:** ![bdeanindy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bdeanindy/32/154_2.png) [@bdeanindy](https://devforum.zoom.us/u/bdeanindy)\
**Post date:** [December 4, 2018, 7:23pm UTC](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609/20 "2018-12-04T19:23:31Z")

</div>

Hello @shahar  
While we can appreciate developer frustration, our code of conduct prohibits name calling or any unprofessional behavior. Please refrain from this in future posts. 😃

[Next page](https://devforum.zoom.us/t/generating-signatures-server-side-for-the-web-sdk-with-node-js/2609.md?page=2)
