Android SDK JWT Token

Description
Initialize SDK with JWT Error Code 1

Which version?
v4.6.21666.0429

Additional context
Hi,
when I try to initialize sdk with jwt token getting errorCode=1
if I try to initialize with sdk_key and secret it works
Followed the steps below

1-builded app with type sdks

2-generated jwt with code below:

String getJWTToken(){
long time = System.currentTimeMillis()/1000 + 60*1000;

    String header = "{\"alg\": \"HS256\", \"typ\": \"JWT\"}";
    String payload = "{\"appKey\": \"" + Constants.SDK_KEY + "\""
            + ", \"iat\": " + String.valueOf(time)
            + ", \"exp\": " + String.valueOf(time)
            + ", \"tokenExp\": " + String.valueOf(time)
            + "}";
    try {
        String headerBase64Str = Base64.encodeToString(header.getBytes("utf-8"), Base64.NO_WRAP| Base64.NO_PADDING | Base64.URL_SAFE);
        String payloadBase64Str = Base64.encodeToString(payload.getBytes("utf-8"), Base64.NO_WRAP| Base64.NO_PADDING | Base64.URL_SAFE);
        final Mac mac = Mac.getInstance("HmacSHA256");
        SecretKeySpec secretKeySpec = new SecretKeySpec(Constants.SDK_SECRET.getBytes(), "HmacSHA256");
        mac.init(secretKeySpec);

        byte[] digest = mac.doFinal((headerBase64Str + "." + payloadBase64Str).getBytes());

        return headerBase64Str + "." + payloadBase64Str + "." + Base64.encodeToString(digest, Base64.NO_WRAP| Base64.NO_PADDING | Base64.URL_SAFE);
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (InvalidKeyException e) {
        e.printStackTrace();
    }
    return null;
}

3-passed jwt to init params

could you help me ? :slight_smile:

Hi @emre,

Thanks for using Zoom SDK. Here is the payload of the JWT token(As mentioned in https://marketplace.zoom.us/docs/sdk/native-sdks/iOS/mastering-zoom-sdk/sdk-initialization):

{
  	"appKey": "string", // Your SDK key
        "iat": long, // access token issue timestamp
        "exp": long, // access token expire timestamp, iat + a time less than 48 hours
	"tokenExp": long // token expire timestamp, MIN:1800 seconds
}

Based on the code snippet, it seems like your iat and exp are the same, and the tokenExp should be a timestamp that is at least iat + 1800 seconds.

Hope this helps. Thanks!

thanks for the reply,
can you explain what is iat and exp?
If could you give me an example with right values for iat, exp and tokenExp it would be perfect :slight_smile:
should I use seconds or milliseconds?

If I get and pass valid JWT can I use it for SSO login?SSO Login
Do I need another token for that?

Thank you

Hi @emre,

iat is the access token issue timestamp and exp is the access token expire timestamp. The exp should be iat + a time less than 48 hours.

An example would be:

{
"appKey": "SDK key",
"iat": 1591184085,
"exp": 1591228800,
"tokenExp": 1591226800
}

This JWT token is for SKD initialization. SSO login will expect a SSO token returned from the IdP.

Thanks!