# Generating SDK Signature Python Sample Code Solution

**URL:** <https://devforum.zoom.us/t/generating-sdk-signature-python-sample-code-solution/84139>\
**Category:** Meeting SDK\
**Created:** [March 3, 2023, 8:25pm UTC](https://devforum.zoom.us/t/generating-sdk-signature-python-sample-code-solution/84139 "2023-03-03T20:25:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurt2](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@kurt2](https://devforum.zoom.us/u/kurt2)\
**Post date:** [March 3, 2023, 8:25pm UTC](https://devforum.zoom.us/t/generating-sdk-signature-python-sample-code-solution/84139/1 "2023-03-03T20:25:26Z")

</div>

I am migrating from Zoom JWT app to Zoom SDK app. The old signature functionality that I was using for the JWT app does not work for SDK app.

Here is the Zoom documentation for how to generate new signature for SDK app: [https://marketplace.zoom.us/docs/sdk/native-sdks/auth/#generate-the-sdk-jwt](https://marketplace.zoom.us/docs/sdk/native-sdks/auth/#generate-the-sdk-jwt)

Unlike before, the docs do not have examples in other languages. I needed it for Python. I saw the question asked here among other places:

> [@Generating SDK Signature Python Sample Code](https://devforum.zoom.us/t/generating-sdk-signature-python-sample-code/67702):
>
> Can we have a sample code that generates the SDK App key signature for Python and other languages besides Node.js, we have tried to base it on top of the JWT Python sample code, but seems have not been able to generate a valid signature.

Solution:  
[https://pyjwt.readthedocs.io/en/stable/](https://pyjwt.readthedocs.io/en/stable/)

```auto
import jwt

SDK_KEY = "sdk"
SDK_SECRET = "secret"

iat = 1675980580
exp = iat + 60 * 60 * 2

oHeader = { "alg": 'HS256', "typ": 'JWT' }

oPayload = {
  "sdkKey": SDK_KEY,
  "mn": 123,
  "role": 0,
  "iat": iat,
  "exp": exp,
  "tokenExp": exp
}

jwtEncode = jwt.encode(
    oPayload,
    SDK_SECRET,
    algorithm="HS256",
    headers=oHeader,
)

```

This gave me same token as when I executed with Zooms node example:

````auto
# eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZGtLZXkiOiJzZGsiLCJtbiI6MTIzLCJyb2xlIjowLCJpYXQiOjE2NzU5ODA1ODAsImV4cCI6MTY3NTk4Nzc4MCwidG9rZW5FeHAiOjE2NzU5ODc3ODB9.HRbG3IfjRw72dbaE7SgxO4uchOBFWdOZm46QKVXHy94
# eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZGtLZXkiOiJzZGsiLCJtbiI6MTIzLCJyb2xlIjowLCJpYXQiOjE2NzU5ODA1ODAsImV4cCI6MTY3NTk4Nzc4MCwidG9rZW5FeHAiOjE2NzU5ODc3ODB9.HRbG3IfjRw72dbaE7SgxO4uchOBFWdOZm46QKVXHy94```
````

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [March 6, 2023, 2:36am UTC](https://devforum.zoom.us/t/generating-sdk-signature-python-sample-code-solution/84139/2 "2023-03-06T02:36:59Z")

</div>

I’m doing something like this

```auto
#pip3 install pyjwt
import jwt
import hashlib
import hmac
import base64
import time
def generateSignature(data,secret):
    encoded_jwt = jwt.encode(data, secret, algorithm="HS256")
    return (encoded_jwt);
if __name__ == ' __main__':
    epoch_time = int(time.time())
    epoch_time_48hours_later=epoch_time+172800
    CLIENT_SECRET="enter your client Secret here"
    CLIENT_ID="enter your client ID here"
    data = { "appKey": CLIENT_ID,
             "iat": epoch_time, 
             "exp": epoch_time_48hours_later, 
             "tokenExp": epoch_time_48hours_later,
             "mn":123456789,
            "role":1
             
            }
    print (generateSignature(data,CLIENT_SECRET))

```
