ZoomController sdk_authenticate getting exception

I am trying to authenticate using my zoom sdk key and secret but in onAuthenticationReturn callback i am getting authResult error code as 9 ( network issue). I am using zoom sdk version v5.14.5.15340. I am executing code using visual studio 19.

Code snippet:

void ZoomController::sdk_authenticate() {
AuthParam authParam;
authParam.appKey = Utility::StringToWString(this->sdkKey);
authParam.appSecret = Utility::StringToWString(this->sdkSecret);
LOG_INFO(TAG)<<“Authenticating Zoom SDK”<<endl;
throwIfNotSuccess(authService->SDKAuth(authParam), LINE);
Timers::set_timer(TimerType::AuthenticationTimer, SDK_CALL_TIMEOUT);
}

Device: Running windows 11 pro on vmware virtual machine.
Host machine: macOs12.6. Chipset: M1pro
Note: This is working fine on my colleague’s machine.

What are the possible reasons for getting network issues error ?

@cai.zoom

5.14.5 has been deprecated on Feb 3rd 2024. This version no longer works

According to Meeting SDK - Minimum version policy, this version will be deprecated on May4. I am trying to move to latest zoom version but before that wanted to test the current version on my windows 11 vm. This auth is not working on windows 11 (seems to work in windows 10).

@cai.zoom you are right on the version.

Anyway starting from 5.14.10, the appKey and appSecret has been removed.

You will need to sign your own JWT token using the appKey and appSecret instead of passing them directly into the parameters.

I’m using Windows 11, and this should not be an issue.

@chunsiong.zoom I upgraded my zoom sdk to latest version. For forming my JWT I followed the instructions given here:

Used the jwt in this code snippet →
AuthContext authContext;
authContext.jwt_token = “XXX”;
LOG_INFO(TAG)<<“Authenticating Zoom SDK”<<endl;
throwIfNotSuccess(authService->SDKAuth(authContext), LINE);

But in onAuthenticationReturn callback I am getting authResult as 5 (Unknown error). What can be possible reasons for this error ?

do you have a sample of the generated JWT token?

Yes @chunsiong.zoom . Sample JWT token:
“eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiIxaVhVZkxZR05oMHFSNmFSc0NqeVFneTN2WWxEVFMwVUxpa0oiLCJpYXQiOjE3MTIzMTIzNTksImV4cCI6MTcxMjM1NzQwNSwidG9rZW5FeHAiOjE3MTIzNTc0MDV9.whobCMMPLuy6LReO3EBGfFGj0E0LzpBlaHfQaJgP9qM”

Valid for 12.5 hours
Note: I used the same token for zoom sdk demo app authentication and its working perfectly there.

@chunsiong.zoom Should i create a new topic for this discussion or should we continue in this thread ?

@cai.zoom since the JWT token works for the sample app, we can deduce that it is not a token issue. It might make more sense to try to capture a log while replicating this issue.

Are you able to capture the log based on this guide?

Yes @chunsiong.zoom I can capture logs, although they are not in human readable format. Attaching log file of my latest run down below:

@chunsiong.zoom Any findings from the logs ?

@cai.zoom , I’ve PM you some findings earlier. wanted to check if you are using proxy server or specific firewall in your environment? There might be some odd URL rewrite done for outgoing traffic

@chunsiong.zoom I have tested this code in windows server 2016 using microsoft remote desktop and in windows 11 using vmware virtual machine. In both these machine I got the result error. I am not using any specific firewall in my environment. I tried authenticating with turning off all my firewalls but still got the same error.
Please let me know the how can i debug this further

Are you able to capture another log? @cai.zoom
Will be good if you can provide for both

Yes sure @chunsiong.zoom . The log I gave above was for windows 11.

The log for windows server 2016:
ZoomIntegration.exe_1.log - Google Drive.

@chunsiong.zoom Does the demo zoom sdk have a different jwt authentication mechanism ?

Sharing code snippet of jwt creation and onAuthenticationReturn

JWT creation

void ZoomController::sdk_authenticate() {
	Config config;
	AuthContext authContext;
	auto appKey = this->sdkKey;
	auto appSecret = this->sdkSecret;

	auto currentTime = std::chrono::system_clock::now();
	auto timeSinceEpoch = std::chrono::system_clock::to_time_t(currentTime);

	Json::Value header;
	header["alg"] = "HS256";
	header["typ"] = "JWT";

	Json::Value payload;
    payload["appKey"] = appKey;
    payload["iat"] = static_cast<Json::Int64>(timeSinceEpoch);
    payload["exp"] = static_cast<Json::Int64>(timeSinceEpoch + config.JWT_EXPIRY_TIME);
    payload["tokenExp"] = static_cast<Json::Int64>(timeSinceEpoch + config.JWT_EXPIRY_TIME);

	// Convert Json::Value to string
    Json::StreamWriterBuilder builder;
    builder["commentStyle"] = "None";
    builder["indentation"] = ""; // Compact JSON representation
    std::string strHeader = Json::writeString(builder, header);
    std::string strPayload = Json::writeString(builder, payload);

	// Base64 encode the header and payload using cppcodec
	std::string encodedHeader = cppcodec::base64_url_unpadded::encode(strHeader);
	std::string encodedPayload = cppcodec::base64_url_unpadded::encode(strPayload);

	std::string signingInput = encodedHeader + "." + encodedPayload;
	std::string hexSignature = hmac<SHA256>(signingInput, appSecret);
	std::vector<uint8_t> binarySignature = hexToBinary(hexSignature);
	std::string encodedSignature = cppcodec::base64_url_unpadded::encode(binarySignature);

    // Final JWT token
    std::string sdkJWT = encodedHeader + "." + encodedPayload + "." + encodedSignature;
	LOG_INFO(TAG) << "sdkJWT: " << sdkJWT << endl;
	authContext.jwt_token = Utility::StringToWString(sdkJWT);
	LOG_INFO(TAG)<<"Authenticating Zoom SDK"<<endl;
	throwIfNotSuccess(authService->SDKAuth(authContext), __LINE__);

	Timers::set_timer(TimerType::AuthenticationTimer, SDK_CALL_TIMEOUT);
}

onAuthenticationReturn

void ZoomController::onAuthenticationReturn(AuthResult authResult) {
	Timers::cancel_timer(TimerType::AuthenticationTimer);
	Json::Value logJson;
	logJson["authenticationReturn"]["authResult"] = authResult;
	logJson["authenticationReturn"]["authResultStr"] = Utility::WStringToString(authResultToString(authResult));
	LOG_INFO(TAG) << Utility::jsonToString(logJson);
	if (authResult == AUTHRET_SUCCESS)
		this->joinMeeting();
	else
		throw CUSTOM_EXCEPTION("Authentication failed with AuthResult = " + to_string(authResult));
}

@cai.zoom you mentioned this is working fine on your colleague’s machine?

The SDK keeps trying to call this URL https://http://zoom.us/sdk/v2/auth which is malformed has it has both https: and http:

Is there some services on your local machine which is doing URL / HTTPS redirects?

Glad to inform that this issue is resolved.
Solution I had earlier set strWebDomain as L"http://zoom.us" and this was working fine for previous authentication method. But when shifting to JWT based auth set strWebDomain as L"https://zoom.us" . This will resolve the issue. cc @chunsiong.zoom Thanks for all the help.

2 Likes