# Use a JWT token instead of appkey and secret?

**URL:** <https://devforum.zoom.us/t/use-a-jwt-token-instead-of-appkey-and-secret/48246>\
**Category:** Android\
**Created:** [April 18, 2021, 7:15pm UTC](https://devforum.zoom.us/t/use-a-jwt-token-instead-of-appkey-and-secret/48246 "2021-04-18T19:15:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abduljav123](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@abduljav123](https://devforum.zoom.us/u/abduljav123)\
**Post date:** [April 18, 2021, 7:15pm UTC](https://devforum.zoom.us/t/use-a-jwt-token-instead-of-appkey-and-secret/48246/1 "2021-04-18T19:15:01Z")

</div>

Hey there, ive integrated zoom sdk into my own app as shown in the docs (importing the commonlib.aar and mobile.aar packages into my personal project). Ive come across a problem now. The app currently has the appkey and secret hardcoded inside it. I would instead like to use a JWT token. I have generated the token as directed in the docs [here](https://marketplace.zoom.us/docs/guides/auth/jwt#generating-jwts) and implemented it in the app as follows:

> public void initializeSdk(Context context , String key, String secret) {  
> ZoomSDK sdk = ZoomSDK.getInstance();  
> ZoomSDKInitParams params = new ZoomSDKInitParams();  
> params.jwtToken = my\_token; // I havent writen the token here cause i dont know if its safe  
> params.domain = “[zoom.us](http://zoom.us)”;  
> params.enableLog = true;  
> ZoomSDKInitializeListener listener = new ZoomSDKInitializeListener() {  
> @Override  
> public void onZoomSDKInitializeResult(int errorCode, int internalErrorCode) {  
> }  
> @Override  
> public void onZoomAuthIdentityExpired() {  
> }  
> };  
> sdk.initialize(context, listener, params);  
> }

However it doesnot work and throws an exception. So, how do i properly use a JWT token with my app? Also in terms of best practice, should i hardcode my token in the app or store it on a backend server and then recieve it from there?

P.s maybe im not generating the token correctly. I want my token to expire after 1 month so i set botk tokenExp and exp 1 month from the current time(in epoch). Is this approach correct or am i doing somrthing wrong?Also how do i make it so that the token never expires and what are the benifits or disadvantages of using such a token that never expires?

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [April 19, 2021, 10:49pm UTC](https://devforum.zoom.us/t/use-a-jwt-token-instead-of-appkey-and-secret/48246/2 "2021-04-19T22:49:26Z")

</div>

Hey @abduljav123,

Thanks for using the dev forum!

> [@abduljav123](#):
>
> However it doesnot work and throws an exception

What is the exception you are getting?

> [@abduljav123](#):
>
> So, how do i properly use a JWT token with my app?

The JWT simply provides an additional layer of security around your key and secret. The nice thing about a JWT is that it is temporary. As in, if your JWT was obtained by someone else you would at least have the protection of an expiration time. The JWT is handed to the SDK the same way key/secret would be, except it allows you to auth the SDK without hardcoding your key and secret directly into the application.

> [@abduljav123](#):
>
> Also in terms of best practice, should i hardcode my token in the app or store it on a backend server and then recieve it from there?

You should not generate your JWT clientside. You should have it reach out to a server that can create one for you when it is needed. Please do not hardcode your key and secret into your application.

> [@abduljav123](#):
>
> I want my token to expire after 1 month so i set botk tokenExp and exp 1 month from the current time(in epoch). Is this approach correct or am i doing somrthing wrong?Also how do i make it so that the token never expires and what are the benifits or disadvantages of using such a token that never expires?

Zoom JWT’s have a maximum lifetime of 48 hours. Generating one to last a month will not work. The disadvantage of a JWT with a long expiration time is that it defeats the purpose of an expiration time. The expiration time protects you (and zoom) from having your JWT compromised and then used. Ideally, you would want the expiration time as short as possible.

Thanks!  
Michael

---

<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:** [May 20, 2021, 8:49am UTC](https://devforum.zoom.us/t/use-a-jwt-token-instead-of-appkey-and-secret/48246/3 "2021-05-20T08:49:59Z")

</div>

Closed on May 20, 2021, 8:49am UTC

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