# Electron SDK error in function sdkauthCB Status 5

**URL:** <https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816>\
**Category:** Electron\
**Created:** [July 22, 2020, 12:17am UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816 "2020-07-22T00:17:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.douglas](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.douglas/32/12250_2.png) [@michael.douglas](https://devforum.zoom.us/u/michael.douglas)\
**Post date:** [July 22, 2020, 12:17am UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/1 "2020-07-22T00:17:17Z")

</div>

Hi Guys, I trying realize login diferents modes in demo SDK Electron but I have no ideia what’s wrong.

**My versions is:**

- Node: v12.0.0
- Mac Catalina: 10.15.6
- Electron: 5.0.2

I’m trying to get the demo to go to the login screen, but when I’m on the auth screen and enter the token, the page keeps refreshing in this function:

```
function sdkauthCB(status) {}

```

I founded the same error in this topic: [Demo keeps refreshing at auth page](https://devforum.zoom.us/t/demo-keeps-refreshing-at-auth-page/24693)

In my case follow my example of jwt token:

```
const jwt = require("jsonwebtoken");
const payloadSDK = {
  appKey: "",
  iat: new Date().getTime() + 5000,
  exp: new Date().getTime() + 5000,
  tokenExp: new Date().getTime(),
};

const tokenSDK = jwt.sign(payloadSDK, "");

console.log(tokenSDK);

```

My **AuthWithJWTToken** is returning 0 the same problem [peterlzhou](https://devforum.zoom.us/u/peterlzhou) having in your topic: [Demo keeps refreshing at auth page](https://devforum.zoom.us/t/demo-keeps-refreshing-at-auth-page/24693).

---

<div class="post-metadata">

**Author:** ![carson.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/carson.zoom/32/785_2.png) [@carson.zoom](https://devforum.zoom.us/u/carson.zoom)\
**Post date:** [July 23, 2020, 10:09pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/2 "2020-07-23T22:09:40Z")

</div>

Hi @michael.douglas,

Thanks for the post. Based on the code snippet you provided to generate the JWT token, it seems like the token expiration time(tokenExp) is before the issue time(iat), please follow the instruction here to generate the JWT token: [https://github.com/zoom/zoom-sdk-electron/blob/master/CHANGELOG.md#new-sdk-initialization-method-using-jwt-token](https://github.com/zoom/zoom-sdk-electron/blob/master/CHANGELOG.md#new-sdk-initialization-method-using-jwt-token)

Hope this helps. Thanks!

Thanks!

---

<div class="post-metadata">

**Author:** ![michael.douglas](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.douglas/32/12250_2.png) [@michael.douglas](https://devforum.zoom.us/u/michael.douglas)\
**Post date:** [July 24, 2020, 4:17pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/3 "2020-07-24T16:17:18Z")

</div>

Hi @carson.zoom many thanks your help, but I trying your suggestion and I changed my code for this mode:

```
const jwt = require("jsonwebtoken");

const getIatExp = (dt, minutes) => {
  return {
    iat: new Date(dt.getTime()).getTime(),
    exp: new Date(dt.getTime() + minutes * 60000).getTime(),
  };
};

const getTokenExpire = (iat, minutes) => {
  return {
    tokenExp: new Date(iat + minutes * 60000).getTime(),
  };
};

const { iat, exp } = getIatExp(new Date(), 30);
const { tokenExp } = getTokenExpire(iat, 60);

const payloadSDK = {
  appKey: "",
  iat: iat,
  exp: exp,
  tokenExp: tokenExp,
};

const tokenSDK = jwt.sign(payloadSDK, "");

console.log("\n *********TOKEN********* \n");
console.log(tokenSDK);
console.log("\n ************************* \n");

console.log("\n *********DEBUG********* \n");
console.log("iat:", new Date(iat).toString());
console.log("exp:", new Date(exp).toString());
console.log("tokenExp:", new Date(tokenExp).toString());
console.log("\n ************************* \n");

console.log("\n *********DEBUG PAYLOAD********* \n");
console.log(payloadSDK);
console.log("\n ************************* \n");

console.log("\n *********DEBUG PAYLOAD TO STRING********* \n");
const debugPayloadSDK = {
  appKey: "",
  iat: new Date(iat).toString(),
  exp: new Date(exp).toString(),
  tokenExp: new Date(tokenExp).toString(),
};
console.log(debugPayloadSDK);
console.log("\n ************************* \n");

```

But I continue received the same error.

**My output console log:**

\*\*\*\*\*\*\*\*\* TOKEN \*\*\*\*\*\*\*\*\*

```
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiJ5V0lVcVdnT2M2QnRUQjlFblBJOVNUWHc1anpsQVpTNUo0bUUiLCJpYXQiOjE1OTU2MDcxOTEyNzYsImV4cCI6MTU5NTYwODk5MTI3NiwidG9rZW5FeHAiOjE1OTU2MTA3OTEyNzZ9.R0Q7-lKIjjJdaTh_sj4uYuL9VoiPZ4CbMtdqIdgAGYI

************************* 

*********DEBUG********* 

iat: Fri Jul 24 2020 13:13:11 GMT-0300 (Brasilia Standard Time)
exp: Fri Jul 24 2020 13:43:11 GMT-0300 (Brasilia Standard Time)
tokenExp: Fri Jul 24 2020 14:13:11 GMT-0300 (Brasilia Standard Time)

************************* 

*********DEBUG PAYLOAD********* 

{ appKey: '',
  iat: 1595607191276,
  exp: 1595608991276,
  tokenExp: 1595610791276 }

************************* 

*******DEBUG PAYLOAD TO STRING******* 

{ appKey: '',
  iat: 'Fri Jul 24 2020 13:13:11 GMT-0300 (Brasilia Standard Time)',
  exp: 'Fri Jul 24 2020 13:43:11 GMT-0300 (Brasilia Standard Time)',
  tokenExp: 'Fri Jul 24 2020 14:13:11 GMT-0300 (Brasilia Standard Time)' }

*************************

```

In:

> const { tokenExp } = getTokenExpire(iat, 60);

I tried this mode too:

> const { tokenExp } = getTokenExpire(iat, 30);

But I continue received the same error code 5.

---

<div class="post-metadata">

**Author:** ![michael.douglas](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.douglas/32/12250_2.png) [@michael.douglas](https://devforum.zoom.us/u/michael.douglas)\
**Post date:** [July 24, 2020, 4:59pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/4 "2020-07-24T16:59:28Z")

</div>

Sorry @carson.zoom,

Finally I founded my error 😄

My first code had errors in TimeStamp.

Now is working, the new code:

```
const jwt = require("jsonwebtoken");

let dt = new Date();

let data = new Date(dt.getTime() + 30 * 60000).getTime();

let iat = Math.floor(Date.now() / 1000);

let exp = Math.floor(data / 1000);

let tokenExpCreate = new Date(dt.getTime() + 60 * 60000).getTime();

let tokenExp = Math.floor(tokenExpCreate / 1000);

const payloadSDK = {

appKey: "",

iat: iat,

exp: exp,

tokenExp: tokenExp,

};

const tokenSDK = jwt.sign(payloadSDK, "");

console.log("\n *********TOKEN********* \n");

console.log(tokenSDK);

console.log("\n ************************* \n");
```

---

<div class="post-metadata">

**Author:** ![carson.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/carson.zoom/32/785_2.png) [@carson.zoom](https://devforum.zoom.us/u/carson.zoom)\
**Post date:** [July 29, 2020, 7:26am UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/5 "2020-07-29T07:26:56Z")

</div>

@michael.douglas Thank you for sharing your findings and glad to hear that the problem has been resolved! Yes, it appears that JavaScript will provide timestamps in milliseconds and the unit of the timestamp in a JWT token should be in second.

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 4, 2020, 6:55pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/6 "2020-10-04T18:55:07Z")

</div>

Hi @michael.douglas @carson.zoom

Thank you for this great post.  
I tried the same thing you provided.  
But I am still getting error code 5 in sdkauthCB

I think it’s because of appKey and appSecret?

I created node.js API for generating jwt token

```
const generateJwtToken = function (req, res) {
    const dt = new Date()
    const data = new Date(dt.getTime() + 30 * 60000).getTime()
    const iat = Math.floor(Date.now() / 1000)
    const exp = Math.floor(data / 1000)
    const tokenExpCreate = new Date(dt.getTime() + 60 * 60000).getTime()
    const tokenExp = Math.floor(tokenExpCreate / 1000)

    const payloadSDK = {
        appKey: 'SDK Key,
        iat,
        exp,
        tokenExp,
    }

    const tokenSDK = jwt.sign(payloadSDK, 'SDK secret')

    res.json({ data: tokenSDK })
}

```

I choose the app type  
 ![Shared with CloudApp](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/optimized/3X/4/b/4ba9c0e5a879be76898d6874a3ca812dc1462a2c_2_690x410.png)

And was able to get the sdk key and sdk secret

 ![](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/c/7/c756d99be2266b001f7e38b0bd653bb2557e1943.png)

But When I try with ‘tokenSDK’(from node.js api) I am getting error code 5 in function sdkauthCB  
 ![Shared with CloudApp](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/optimized/3X/f/c/fcd954b21b9a6255d5d1daf2cd6275a1d650f851_2_690x400.gif)

I am in trouble with this for 1 week but can’t still find a solution.

Could you please help me what the problem could be?

My development environment:  
node v12.18.4  
electron 5.0.2  
MAC OS Catalina 10.15.7

Thank you

---

<div class="post-metadata">

**Author:** ![geekvijay](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/geekvijay/32/4428_2.png) [@geekvijay](https://devforum.zoom.us/u/geekvijay)\
**Post date:** [October 6, 2020, 5:37am UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/7 "2020-10-06T05:37:45Z")

</div>

> <https://gist.github.com/geekvijay/9aa9809e5691bf57ea0253ce62ad0ba6>

Try this code to generate jwt token, Hope this works for you.

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 10:47am UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/8 "2020-10-06T10:47:05Z")

</div>

Hi @geekvijay  
Thank you for replying.

I tried the code you provided for generating jwt token.  
But I am still getting the same error code.

---

<div class="post-metadata">

**Author:** ![geekvijay](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/geekvijay/32/4428_2.png) [@geekvijay](https://devforum.zoom.us/u/geekvijay)\
**Post date:** [October 6, 2020, 2:54pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/9 "2020-10-06T14:54:28Z")

</div>

@simon.andrei879 one more question is your account is on paid plan?  
I guess it works in paid account only.

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 3:08pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/10 "2020-10-06T15:08:40Z")

</div>

@geekvijay  
Uh, so it works on paid plan only?  
I am using free account  
But I was unable to find the mentions about it in Zoom SDK document.  
Can you please be more specific about this?

---

<div class="post-metadata">

**Author:** ![geekvijay](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/geekvijay/32/4428_2.png) [@geekvijay](https://devforum.zoom.us/u/geekvijay)\
**Post date:** [October 6, 2020, 3:45pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/11 "2020-10-06T15:45:44Z")

</div>

Sorry, for the wrong info. it’s working in my free account too.  
are you changing the domain on first screen, it has to be `https://www.zoom.us`

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 3:47pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/12 "2020-10-06T15:47:16Z")

</div>

@geekvijay  
Yes, it’s [https://www.zoom.us](https://www.zoom.us)

---

<div class="post-metadata">

**Author:** ![geekvijay](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/geekvijay/32/4428_2.png) [@geekvijay](https://devforum.zoom.us/u/geekvijay)\
**Post date:** [October 6, 2020, 4:51pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/13 "2020-10-06T16:51:49Z")

</div>

try this token `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiJPT0dEUmJXczNnQXdDODhWTEZ3MVk0UjFoTXFTQmJaVks5cVoiLCJpYXQiOjE2MDIwMDI5NDEsImV4cCI6MTYwMjA4OTM0MSwidG9rZW5FeHAiOjE2MDIwODkzNDF9.eltal6Ad6Q2wZOHjfeACTfUx9SzIIZkbRZ2hPDfpKNk`

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 5:03pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/14 "2020-10-06T17:03:59Z")

</div>

@geekvijay  
Wow!  
It’s working!  
How did you generate that token?

---

<div class="post-metadata">

**Author:** ![geekvijay](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/geekvijay/32/4428_2.png) [@geekvijay](https://devforum.zoom.us/u/geekvijay)\
**Post date:** [October 6, 2020, 5:07pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/15 "2020-10-06T17:07:03Z")

</div>

its generated using my accounts sdk key and Secrete, there must be some problem with your sdk key and secret

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 5:15pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/16 "2020-10-06T17:15:50Z")

</div>

@geekvijay  
I am not sure it’s the right way for creating sdk key and secret  
 ![](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/8/3/835d791b4d423a2c1dfcc7e66d7a75bba80dcfe4.png)

[![](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/c/7/c756d99be2266b001f7e38b0bd653bb2557e1943.png) ](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/c/7/c756d99be2266b001f7e38b0bd653bb2557e1943.png)

By the way… how do you create them?

---

<div class="post-metadata">

**Author:** ![geekvijay](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/geekvijay/32/4428_2.png) [@geekvijay](https://devforum.zoom.us/u/geekvijay)\
**Post date:** [October 6, 2020, 5:21pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/17 "2020-10-06T17:21:53Z")

</div>

I am using same key and and secret, can you regenerate secret and try again.

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 5:28pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/18 "2020-10-06T17:28:49Z")

</div>

I tried to regenerate sdk secret but still failed

Generated token using this codes

> <https://gist.github.com/geekvijay/9aa9809e5691bf57ea0253ce62ad0ba6>

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 7:38pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/19 "2020-10-06T19:38:52Z")

</div>

@geekvijay  
If possible can you share with me yr sdk key and secret?  
I know this would be the idiot request, but I’d like to try  
You may regenerate yr secret in some minutes

---

<div class="post-metadata">

**Author:** ![simon.andrei879](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@simon.andrei879](https://devforum.zoom.us/u/simon.andrei879)\
**Post date:** [October 6, 2020, 11:59pm UTC](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816/20 "2020-10-06T23:59:43Z")

</div>

@geekvijay  
Finally, I found the issue and got it’s running.

Thank you for your help!

[Next page](https://devforum.zoom.us/t/electron-sdk-error-in-function-sdkauthcb-status-5/24816.md?page=2)
