I have the following code in Javascript:
function startMeet(meetingId) {
const iat = Math.round((new Date().getTime() - 30000) / 1000);
const exp = iat + 60 * 60 * 2;
const oHeader = {alg: 'HS256', typ: 'JWT'};
const oPayload = {
sdkKey: '<?= $sdkkey ?>',
mn: meetingId,
role: 1,
iat: iat,
exp: exp,
appKey: '<?= $sdkkey ?>',
tokenExp: iat + 60 * 60 * 2
};
const sHeader = JSON.stringify(oHeader);
const sPayload = JSON.stringify(oPayload);
const sdkJWT = KJUR.jws.JWS.sign('HS256', sHeader, sPayload, '<?= $sdkSecret ?>');
const client = ZoomMtgEmbedded.createClient();
let meetingSDKElement = document.getElementById('zmmtg-root');
$.ajax(
{
method: "GET",
url: "/providers/getZoomDak",
}).done(function (msg)
{
msg = JSON.parse(msg);
client.init({ enforceMultipleVideos: true, minimumParticipantsForGalleryView: 2, zoomAppRoot: meetingSDKElement, language: 'en-US', customize: {video: {disableDraggable: true, isResizable: false, viewSizes: {default: {width: 800, height: 500}, ribbon: {width: 300, height: 700}}}}});
client.join({
sdkKey: '<?= $sdkkey ?>',
signature: sdkJWT, // role in SDK signature needs to be 1
meetingNumber: meetingId,
password: '23421321',
userName: "Don Carson Don",
zak: msg.zak // the host's zak token
}).then(() => {
stream = client.getMediaStream()
client.getAllUser().forEach((user) => {
if (user.bVideoOn) {
stream.renderVideo(document.querySelector('#participants-canvas'), user.userId, 960, 540, X_CORD, Y_CORD, 2)
}
})
});
client.on('video_statistic_data_change', (payload) => {
$('.react-draggable').removeClass('react-draggable');
console.log('emit', payload);
});
});
}
It works when role is 0, but I get JOIN_MEETING_FAILED when I switch to role equals 1. From the Network section of developer tools I get the following from the zoom server: FailedFromWeb, RESULT_UNKOWN_ERROR, 200
I thought it was the zak token, but that seems fine.
What is weird is that I get the popup saying Failed to join Meeting. When I click on retry, I get “Signature is Invalid”.