Getting invalid token signature

Description
I created an app and copied the JWT token which is valid for 1 day by going into app credentials section and made a call to create a meeting and successfully got a response. However, when I generate credentials within code using JWT example given here I get an error. Code example -

async function getToken(){
	const APIKey = "API key here";
	const secret = "secret here";
	 const payload = {
	    iss: APIKey,
	    exp: ((new Date()).getTime() + 5000)
	};
	const token = jwt.sign(payload, APISecret);
	return jwt.sign(payload, secret);	
}

async function createMeeting(token){
	email = "user email here";

	let config = {
	    headers: { Authorization: `Bearer ${token}` }
	};
	let data = {
		  "topic": "test create meeting",
		  "type": 1,
		  "settings": {
		    "host_video": "true",
		    "participant_video": "true"
		  }
	};

	let resp = await axios.post( 
	  "https://api.zoom.us/v2/users/" + email + "/meetings",
	  data,
	  config
	);
	console.log(resp.data);

	return "done";
}

async function f(){
	let token = await getToken();
	console.log("token -> ", token);
	await createMeeting(token);
}

f();

Error
{“code”:124,“message”:“The Token’s Signature resulted invalid when verified using the Algorithm: HmacSHA256”}

Which App Type (OAuth / Chatbot / JWT / Webhook)?
JWT

Which Endpoint/s?
Problem exists with all endpoints.

How To Reproduce (If applicable)
Steps to reproduce the behavior:

  1. run the code given above

Screenshots (If applicable)
Steps explain everything I am doing

Additional context
N/A

Hey @orbot

Thanks for posting on the Zoom Devforum! I am still learning, but I will try my best to help answer your question. :slightly_smiling_face:

Checkout these related threads that may have the answer you are looking for:

If these threads did not help, please let us know by replying back here and someone from the Developer Relations team will get back to you shortly.

Thanks,
DeveloperBot

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