Meeting SDK v2.18.2 "Token Error" on instant start

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

@ventura can you try to change the role=0 test again

@JackYang

The error I get for this:

“Joining meeting timeout. The meeting number is not found.”

My goal was to let the admin generate a meeting and immediately start it and my web app will handle the sharing of the link and all that; Ideally this ought to be done without zoom redirects. The docs state that I should use the following url: /users/me/zak however this one requires a scope of user_zak:read which isn’t available for server to server oauth which gives me an account ID which is required to make an access token which is required to get the ZAK. So I keep getting denied because of no valid scopes for the url in the docs.

The scope is available for the normal oauth app (user managed) however it does not provide an account ID so I can’t generate an access token. I did try mixing my server oauth account ID and my normal oauth client ID and secret however that didn’t work out.

It kind of feels like a cache22 and the docs are pretty mysterious about the right way to do this and unfortunately the JWT zak has been deprecated of which all community posts here only reference its use.

Edit: Added ‘@’

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.