I’ve checked all posts here relating to this and couldn’t find an answer that solved it for me.
So I have a server to server oath app and then the frontend with the web SDK. I generate the ZAK and Access Token on the server as such (as owner if role = 1):
const accessTokenReq = await fetch(
`https://zoom.us/oauth/token?grant_type=account_credentials&account_id=${ZOOM_OAUTH_ACC_ID}`,
{
method: "POST",
headers: { Authorization: `Basic ${ZOOM_OATH_BASIC_AUTH}` },
}
);
const { access_token } = await accessTokenReq.json();
const zakReq = await fetch(
`https://api.zoom.us/v2/users/me/token?type=zak`,
{
method: "GET",
headers: {
Authorization: `Bearer ${access_token}`,
},
}
);
const { token } = await zakReq.json();
I then gen the signature as such:
const iat = Math.round(new Date().getTime() / 1000) - 30;
const exp = iat + 60 * 60 * 3;
const oHeader = { alg: "HS256", typ: "JWT" };
const oPayload = {
sdkKey: ZOOM_CLIENT_ID,
mn: meetingNumber,
role: role,
iat: iat,
exp: exp,
appKey: ZOOM_CLIENT_ID,
tokenExp: iat + 60 * 60 * 3,
};
const sHeader = JSON.stringify(oHeader);
const sPayload = JSON.stringify(oPayload);
const signature = KJUR.jws.JWS.sign(
"HS256",
sHeader,
sPayload,
ZOOM_CLIENT_SECRET
);
NOTE: ZOOM_CLIENT_SECRET
and ZOOM_CLIENT_ID
are for the meeting sdk app type and ZOOM_OAUTH_ACC_ID and ZOOM_OATH_BASIC_AUTH are for the server to server oauth app type.
I then return them to the client annd start/join the meeting like:
const initMeeting = async () => {
ZoomMtg.setZoomJSLib("https://source.zoom.us/2.18.2/lib", "/av");
ZoomMtg.preLoadWasm();
ZoomMtg.prepareWebSDK();
ZoomMtg.i18n.load("en-US");
ZoomMtg.i18n.reload("en-US");
const zoomAuth = await getSignature();
if (!zoomAuth) {
router.refresh();
return;
}
const { key, signature, zak } = zoomAuth;
const el = document.getElementById("zmmtg-root");
el ? (el.style.display = "block") : null;
ZoomMtg.init({
leaveUrl: "https://demo.venturasolutions.org/thanks",
success: (success: any) => {
console.log("success\n", success);
ZoomMtg.join({
signature: signature,
sdkKey: key,
meetingNumber: toNumeric(),
passWord: "",
userName: cookie.name,
userEmail: "",
tk: "",
zak: cookie.admin ? zak : undefined,
success: (success: any) => {
console.log("success 2\n", success);
},
error: (error: any) => {
console.log("error 2\n", error);
},
});
},
error: (error: any) => {
console.log("error\n", error);
},
});
};
I’m getting the following errors:
{type: 'VIDEO', evt: 'ERROR', errorCode: 'NOT_CONNECTED', data: undefined}
and:
{method: 'join', status: false, result: 'Not support start meeting via tokens', errorMessage: 'Token error', errorCode: 3265}
I am using nextjs v13.4.8 and idk what the issue is, can I get some help? The server calls are done on the client so there’s no build time caching from ssr