How do I generate a valid signature from PHP?

Hi,
i used php code to generate the signature

public static function generate_signature($api_key, $api_secret, $meeting_number, $role)
    {
        //Set the timezone to UTC
        date_default_timezone_set(config('app.timezone'));
        $time = time() * 1000 - 30000; //time in milliseconds (or close enough)
        $data = base64_encode($api_key . $meeting_number . $time . $role);
        $hash = hash_hmac('sha256', $data, $api_secret, true);
        $_sig = $api_key . "." . $meeting_number . "." . $time . "." . $role . "." . base64_encode($hash);
        //return signature, url safe base64 encoded
        return rtrim(strtr(base64_encode($_sig), '+/', '-_'), '=');
    }

but i received this error

{method: ‘join’, status: false, result: ‘Invalid signature.’, errorMessage: ‘Signature is invalid.’, errorCode: 3712}

I used SDK Key & SDK Secret. When I use JWT credentials I’m getting this error

{method: ‘join’, status: false, result: null, errorMessage: ‘Sdk key length error, must 36’, errorCode: 4003}

this is the wrong version for SDK JWT signature

you can easily distinguish the signature routines:

  • JWT Signature (deprecated) → time in Milliseconds
  • SDK JWT Signature → time in Seconds

use:

Jürgen

1 Like

Thank you so much @j.schoenemeyer I was looking for a solution for days. I am glad this issue was solved now!

@j.schoenemeyer,

Thank you for sharing your solution for generating a valid signature from PHP!

how about sdk 2.7.0 version?

how about sdk 2.7.0 version generate from php? any example? thanks before.

2.7.0 uses always SDK JWT Signature , JWT Signature is not supportet anymore

version 2.7.0

General

Removed

  1. API Key property. Migrate to SDK Key for versions 2.7.0 and above

if you have implementated SDK JWT Signature for versions before 2.7.0, there is no difference

1 Like

@rakhap ,

@j.schoenemeyer is correct, there is no difference , you should be able use the same code to generate a SDK JWT signature for 2.7.0.

can you help? I have successfully joined to zoom, but the camera can’t open with an error like this
err-zoom-sdk

i’m using Web SDK 2.7.0 Component View

thanks