SDK Initialization


Contents

1. Initialize the Zoom SDK

2. Log feature

Main Thread

Please note that SDK initialization and all API call must run in Main Thread.

1. Initialize the Zoom SDK

To run all services, the Zoom SDK needs to be initialized. The ZoomSDK object exposes a generic interface to allow initialization, authentication, and configuration.

To initialize the object, first implement the ZoomSDKInitializeListener in your class along with your AuthConstants (access credentials).

public class InitAuthSDKHelper implements AuthConstants, ZoomSDKInitializeListener {
  ...
}

Next, instantiate a ZoomSDK object by calling .getInstance() and then .initialize(). Pass in the context, listener along with your init params.

ZoomSDK sdk = ZoomSDK.getInstance();
sdk.initialize(Context, ZoomSDKInitializeListener, ZoomSDKInitParams)

ZoomSDKInitParams will include your access credentials for authentication, and can be either a JWT or SDK Key & Secret.

For a guide on setting up your SDK Client Key and Client Secret, reference our guide to Create an SDK App on the Marketplace.

Please do not use raw IP address as the web domain

Please do not use raw IP address as the web domain as it will cause vulnerability issues. If you would like to learn why, please see our security practices for more information.

Authenticate using Client Key / Secret

To initialize with Client Key and Secret, include both a appKey and appSecret as fields of the ZoomSDKInitParams object.

If the appKey and appSecret is not passed, a jwtToken should be used.

Authenticate using JWT

As of Android SDK version 4.4.57220.1211, the Android SDK can be initialized using JWT for added security, convenience and versatility.

To initialize with JWT, pass a jwtToken string as a field of the ZoomSDKInitParams object.

If no JWT is passed, appKey and appSecret should be used.

Composing JWT for SDK Initialization

Zoom SDKs support JWTs generated with JWT.io libraries on a backend server. While other libraries can be used to create JWT, these recommended libraries are the most robust.

JWT is generated with three core parts: Header, Payload, and Signature. When combined, these parts are separated by a period to form a token: aaaaa.bbbbb.cccc. Follow this template to compose your payload for SDK initialization.

For further information, reference our guide to JSON Web Tokens (JWT).

Header

The Header includes the specification of the signing algorithm and the type of token.

{
	"alg": "HS256",
	"typ": "JWT"
}

Payload

The payload of a JWT contains the claims of the token, or the pieces of information being passed about the user and any metadata required.

{
	"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 time, MIN:1800 seconds
}

The minimum value of tokenExp should be at least 30 minutes, otherwise, the authentication request will be rejected.

Signature

To create a signature for the JWT, the header and payload must be encoded with the SDK Secret through an HMAC SHA256 algorithm.

HMACSHA256(
	base64UrlEncode(header) + "." +
	base64UrlEncode(payload),
	YOUR_SDK_SECRET
)

Your signature does not need to be base64 encoded. Once the token is generated, do not reveal or publish it. It is highly recommended to handle your SDK Key and Secret and generate a JWT in a backend server to be consumed by your application. Do not generate JWT in a production environment.

ZoomSDKInitParams initParams = new ZoomSDKInitParams();
            initParams.jwtToken = SDK_JWTTOKEN;
            initParams.enableLog = true;
            initParams.domain=AuthConstants.WEB_DOMAIN;
            mZoomSDK.initialize(context, this, initParams);

The parameters in the function (from first to last):

Parameter Definition
Context Android context
appKey Your SDK key
appSecret Your SDK secret
listener Listener for initialize result

This function will not return anything upon successful execution.

Handling Successful Response

In order to initialize SDK successfully, you need to override the following method with ZoomSDKInitializeListener implemented:

/**
 * init sdk callback
 * @param errorCode defined in {@link us.zoom.sdk.ZoomError}
 * @param internalErrorCode Zoom internal error code
 */
@Override
public void onZoomSDKInitializeResult(int errorCode, int internalErrorCode) {
  ...
}

If a successful response is returned, you can also try to login a user automatically by calling the tryAutoLoginZoom() method:

/**
 * init sdk callback
 * @param errorCode defined in {@link us.zoom.sdk.ZoomError}
 * @param internalErrorCode Zoom internal error code
 */
@Override
public void onZoomSDKInitializeResult(int errorCode, int internalErrorCode) {
  ...
    if (errorCode != ZoomError.ZOOM_ERROR_SUCCESS) {
			Toast.makeText(this, "Failed to initialize Zoom SDK. Error: " + errorCode + ", internalErrorCode=" + internalErrorCode, Toast.LENGTH_LONG).show();
		} else {
			Toast.makeText(this, "Initialize Zoom SDK successfully.", Toast.LENGTH_LONG).show();
			if (mZoomSDK.tryAutoLoginZoom() == ZoomApiError.ZOOM_API_ERROR_SUCCESS) {
        UserLoginCallback.getInstance().addListener(this);
				showProgressPanel(true);
			} else {
				showProgressPanel(false);
			}
		}
  ...
}

2. Log feature

The log feature is introduced with SDK v4.3.53571.0118, you can enable log feature when initializing Zoom SDK with the following method:

Initialize with log

ZoomSDK sdk = ZoomSDK.getInstance();
sdk.initialize(context, APP_KEY, APP_SECRET, (ZoomSDKInitializeListener)this, (enableLog)true);

Once the log feature is initialized, a log file will be created inside the path: /Android/data/(or your app's name)/logs/

Path of the log
Path of the log

The log file has a 5MB storage capacity(fixed). Once it reaches the maximum capacity, it will auto re-record from the beginning and override the previous data.