# Strange error of " Signature is invalid"

**URL:** <https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630>\
**Category:** API and Webhooks\
**Created:** [June 5, 2023, 1:18pm UTC](https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630 "2023-06-05T13:18:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoomema2020](https://avatars.discourse-cdn.com/v4/letter/z/35a633/32.png) [@zoomema2020](https://devforum.zoom.us/u/zoomema2020)\
**Post date:** [June 5, 2023, 1:18pm UTC](https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630/1 "2023-06-05T13:18:20Z")

</div>

**API Endpoints**

> **[GitHub - zoom/meetingsdk-javascript-sample: Use the Zoom Meeting SDK in...](https://github.com/zoom/meetingsdk-javascript-sample)**
>
> Use the Zoom Meeting SDK in (vanilla) JavaScript. Contribute to zoom/meetingsdk-javascript-sample development by creating an account on GitHub.

\*\*Unexplainable Signature is invalid \*\*  
I am using server to server oAuth for my app on zoom, my servers backend is php. I am currently using basic account but would move  
to paid version after completing the code. This is the code I have used in php  
```  
$meeting\_number = 98745525626;//this is a random meeting number but actual number is from zoom  
$password = ‘random\_password’;  
$encrypted\_password = ‘123456’;  
$host\_email = ‘my email as registered on zoom’;

````
//get zoom video meeting credential
$sdk_key = env('ZOOM_CLIENT_ID');
$sdk_secret = env('ZOOM_CLIENT_SECRET');
$role = 1;//$request->role;

	 function base64url_encode($str) {
		return rtrim(strtr(base64_encode($str), '+/', '-_'), '=');
	}

	 
	$headers = array(
		'alg' => 'HS256', //alg is required
		'typ' => 'JWT'
		);

	date_default_timezone_set("UTC");
	$time = time() - 30;
	$exp = $time + 3600 * 2;	
	$payload = array(
		'sdkKey' => $sdk_key,
		'mn' => $meeting_number, // meeting number that you send via post request
		'role' => $role, // 0 guest or 1 host via post request 
		'iat' => $time,
		'exp' => $exp,
		'tokenExp' => $exp,
	);

	//the followinq were returned to zoom
	//test 1
	function generate_jwt($headers, $payload, $key) {
		$headers_encoded = base64url_encode(json_encode($headers));
		
		$payload_encoded = base64url_encode(json_encode($payload));
		
		$signature = hash_hmac('SHA256', "$headers_encoded.$payload_encoded", $key, true);
		$signature_encoded = base64url_encode($signature);
		
		$jwt = "$headers_encoded.$payload_encoded.$signature_encoded";
		
		return $jwt;
	}
	

	$signature = generate_jwt($headers, $payload, $sdk_secret);
	
	return $signature
	
	/*
		test 2
		$signature = \Firebase\JWT\JWT::encode($payload, $sdk_secret, 'HS256');
		return $signature;
		
		Both gave me same result
	*/

```

````

in my frontend

```
ZoomMtg.join({
		signature:$signature_from_php,
		sdkKey:$sdk_key_from_php,
		meetingNumber:meetingNumber_from_php,
		passWord: password_from_php,
		userName:'my online alias',
		userEmail:'email_on_zoom_account',
		success: (success) => {
		  console.log(success)
		},
		error: (error) => {
		  console.log(error)
		},
	  })

```

But this keeps on giving me the error message

> { method: “join”, status: false, result: “Invalid signature.”, errorMessage: “Signature is invalid.”, errorCode: 3712 }

When I tried it some hours later the error message became.

> { method: “join”, status: false, result: “The signature has expired.”, errorMessage: “The signature has expired.”, errorCode: 3705 }

This shows that it was somehow captured and now expired.

I have checked the local time and even sycned my local time to be the same thing that was set in my zoom account. I have ensured that  
i have set the appropriate scope that I think are needed.

> is there any specific configuration that i need to do in my developer account  
> aside from creating my app.

I have already obtained my client id and client secret in my appp.  
What could be the reason why I am still having this error, could the basic account be affecting the result?

> Could there be any error in my configuration which I have not taken note of?

> Is there any other thing in my code that is making it not to work?

> is there a way I can reverse the signature using php to confirm what I sent is correct?

> What am i not doing right?

I have used new created meetings, upcoming meetings, expired meetings. It was the same message I have been getting.

**UPDATE**  
I have used the clientid and secret t create new meeting and it worked

Along side with the error message I got the following errors in the browser console

> Cookie “zm\_aid” has been rejected because it is already expired. info

> Cookie “zm\_haid” has been rejected because it is already expired. info

> Cookie “zm\_tmaid” has been rejected because it is already expired. info

> Cookie “zm\_htmaid” has been rejected because it is already expired. info

---

<div class="post-metadata">

**Author:** ![j.schoenemeyer](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@j.schoenemeyer](https://devforum.zoom.us/u/j.schoenemeyer)\
**Post date:** [June 5, 2023, 8:36pm UTC](https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630/2 "2023-06-05T20:36:50Z")

</div>

you should first try, if your client id and client secret is working

> [@Invalid Signature error after changing account email](https://devforum.zoom.us/t/invalid-signature-error-after-changing-account-email/89062/5):
>
> first synch your computer/server with a global time server then you should check if your Meeting SDK app on Zoom App Marketplace works flawless use to test the Zoom Meeting SDK web sample on github (-\> CDN version) the CDN version is ready to use in a few simple steps CDN/js/index.js:20 var CLIENT\_ID = "YOUR\_CLIENT\_ID\_OR\_SDK\_KEY";; CDN/js/index.js:26 var CLIENT\_SECRET = "YOUR\_CLIENT\_SECRET\_OR\_SDK\_SECRET; CDN/js/index.js:112 ... "/meeting.html?" // replace '/' with './'

you should try connect with role = 0 (attendee) and with role = 1 (host)

and here more infos for troubleshooting signature

> **[Troubleshooting Zoom Meeting SDK signature validation](https://dev.to/zoom/troubleshooting-zoom-meeting-sdk-signature-validation-1hln)**
>
> In this guide, we’ll cover common issues you may run into when generating a signature for the Zoom...

---

<div class="post-metadata">

**Author:** ![zoomema2020](https://avatars.discourse-cdn.com/v4/letter/z/35a633/32.png) [@zoomema2020](https://devforum.zoom.us/u/zoomema2020)\
**Post date:** [June 6, 2023, 2:24am UTC](https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630/3 "2023-06-06T02:24:15Z")

</div>

@j.schoenemeyer I thank u. Still working on it. made an update

---

<div class="post-metadata">

**Author:** ![zoomema2020](https://avatars.discourse-cdn.com/v4/letter/z/35a633/32.png) [@zoomema2020](https://devforum.zoom.us/u/zoomema2020)\
**Post date:** [June 6, 2023, 12:26pm UTC](https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630/4 "2023-06-06T12:26:02Z")

</div>

@j.schoenemeyer thank you for the troubleshooting that you led me to. I discorvered that I cant use sdk for server-to-server oauth. I am still stuck on what to do. Is it like I am the only one stuck, there seems not be any material on server to server

---

<div class="post-metadata">

**Author:** ![zoomema2020](https://avatars.discourse-cdn.com/v4/letter/z/35a633/32.png) [@zoomema2020](https://devforum.zoom.us/u/zoomema2020)\
**Post date:** [June 6, 2023, 12:26pm UTC](https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630/5 "2023-06-06T12:26:54Z")

</div>

@j.schoenemeyer thank you for the troubleshooting that you led me to. I discorvered that I cant use sdk for server-to-server oauth. I am still stuck. I have to open a new topic [Server-to-server oauth meeting](https://devforum.zoom.us/t/server-to-server-oauth-meeting/89708)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [June 9, 2024, 4:03am UTC](https://devforum.zoom.us/t/strange-error-of-signature-is-invalid/89630/6 "2024-06-09T04:03:51Z")

</div>

Closed on June 9, 2024, 4:03am UTC

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