I have created a meeting using api and jwt app API key and secret key. Then I installed @zoomus/websdk the n when I click the join meeting in web a signature is generated in backend with PHP and then join the meeting but it says type: ‘JOIN_MEETING_FAILED’, reason: ‘Fail to join the meeting.’, errorCode: 200
code to generate signature in backend:
public function generate_signature($meeting_number, $role)
{
$api_key = config('zoom.zoom_sdk_key');
$api_secret = config('zoom.zoom_sdk_secret');
$now = Carbon::now();
//build the headers
$headers = ['alg' => 'HS256', 'typ' => 'JWT'];
$headers_encoded = $this->base64url_encode(json_encode($headers));
$exp = $now->addSeconds(1800)->timestamp;
//build the payload
$payload = [
'sdk_key' => $api_key,
'mn' => $meeting_number,
'role' => $role,
'iat' => $now->timestamp,
'exp' => $exp,
'app_key' => $api_key,
'tokenExp' => $exp
];
$payload_encoded = $this->base64url_encode(json_encode($payload));
//build the signature
$signature = hash_hmac('SHA256', "$headers_encoded.$payload_encoded", $api_secret, true);
$signature_encoded = $this->base64url_encode($signature);
$token = "$headers_encoded.$payload_encoded.$signature_encoded";
// Log::debug($token);
return $token;
}
private function base64url_encode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
In web to join the code is:
async getSignature() {
await axios.post(this.signatureEndpoint, {
meeting_number: this.$props.meetingNumber,
role: this.$props.role
})
.then(res => {
console.log(res.data.signature);
this.startMeeting(res.data.signature);
})
.catch(error => {
console.log(error);
});
},
startMeeting(signature) {
let meetingSDKElement = document.getElementById('meetingSDKElement');
this.client.init({
debug: true,
zoomAppRoot: meetingSDKElement,
language: 'en-US',
customize: {
meetingInfo: ['topic', 'host', 'mn', 'pwd', 'telPwd', 'invite', 'participant', 'dc', 'enctype'],
toolbar: {
buttons: [
{
text: 'Custom Button',
className: 'CustomButton',
onClick: () => {
console.log('custom button');
}
}
]
}
}
});
this.client.join({
sdkKey: Meeting-SDK-KEY
signature: signature,
meetingNumber: this.$props.meetingNumber,
password: this.$props.passWord,
userName: this.$props.userName,
//userEmail: this.$props.userEmail,
// tk: this.registrantToken
})
}