Electron SDK error in function sdkauthCB Status 5

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

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 having in your topic: Demo keeps refreshing at auth page.

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

Hope this helps. Thanks!

Thanks!

Hi @carson_chen 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.

Sorry @Carson_Chen,

Finally I founded my error :smile:

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");
1 Like

@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.

Hi @michael.douglas @Carson_Chen

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

And was able to get the sdk key and sdk secret

But When I try with ‘tokenSDK’(from node.js api) I am getting error code 5 in function sdkauthCB
Shared with CloudApp

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

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

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.

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

@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?

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

@geekvijay
Yes, it’s https://www.zoom.us

try this token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiJPT0dEUmJXczNnQXdDODhWTEZ3MVk0UjFoTXFTQmJaVks5cVoiLCJpYXQiOjE2MDIwMDI5NDEsImV4cCI6MTYwMjA4OTM0MSwidG9rZW5FeHAiOjE2MDIwODkzNDF9.eltal6Ad6Q2wZOHjfeACTfUx9SzIIZkbRZ2hPDfpKNk

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

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

@geekvijay
I am not sure it’s the right way for creating sdk key and secret

By the way… how do you create them?

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

I tried to regenerate sdk secret but still failed

Generated token using this codes

@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

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

Thank you for your help!