Meeting SDK Type and Version
@zoomus/websdk: 2.8.0
Type: Component View
Description
Randomly getting “Signature is invalid” error while joining zoom meeting. But when I retries to join zoom meeting with same signature then after some retries or some time I can able to join with the same signature.
I am generating signature at the server side with role = 0.
Error?
{type: ‘JOIN_MEETING_FAILED’, reason: ‘Signature is invalid.’, errorCode: 3712}
Following is the signature generation code snippet.
private JSONObject tokenHeader = new JSONObject()
.put("alg", "HS256")
.put("typ", "JWT");
public String generateSignature(String meetingId, int role) {
long currentTimestamp = Math.round(System.currentTimeMillis()/1000);
long tokenExpiryTime = currentTimestamp + zoomSDKJWTTokenExpiryInHr * 60 * 60;
JSONObject payload = new JSONObject()
.put("sdkKey", zoomSDKKey)
.put("mn", meetingId)
.put("role", role)
.put("iat", currentTimestamp)
.put("exp", tokenExpiryTime)
.put("appKey", zoomSDKKey)
.put("tokenExp", tokenExpiryTime);
try {
Algorithm algorithm = Algorithm.HMAC256(zoomSDKSecret);
String signature = JWT.create()
.withHeader(tokenHeader.toMap())
.withPayload(payload.toMap())
.sign(algorithm);
return signature;
} catch (JWTCreationException exception){
throw new RuntimeException("unable to generate signature");
}
}
Following is the typescript code snippet to join meeting:
const clientInit = (): typeof EmbeddedClient | undefined => {
if(!containerRef.current) {
return;
}
const _client: typeof EmbeddedClient = ZoomMtgEmbedded.createClient();
_client.init({
debug: false,
zoomAppRoot: containerRef.current,
language: 'en-US',
customize: {
activeApps: {
popper: undefined
},
meetingInfo: [],
video: {
isResizable: true
}
},
})
.catch((err: any) => {
console.error("unable to init zoom client", err);
})
setClient(_client);
return _client;
}
const clientJoin = (_client?: typeof EmbeddedClient) => {
if(!_client) {
console.error("client not found");
return ;
}
console.info("joining client");
_client.join({
sdkKey: zoomConnectionData.sdkKey,
signature: zoomConnectionData.signature,
meetingNumber: zoomConnectionData.meetingNumber,
password: zoomConnectionData.password,
userName: currentUser.name,
userEmail: currentUser.email,
success: handleClientJoined,
error: handleErrorOnJoin
})
.then((res) => {
handleClientJoined();
})
.catch((err) => {
handleErrorOnJoin(err);
})
}