API Endpoints
**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