Invalid Parameter - signature length error, 0 < length < 150

Hi Everyone,

I am trying to create a zoom meeting and then join it as host. I generate the toke and then create the meeting just fine but when I try to join in I get the error above. I am including screenshots showing the meeting being created and the error I am receiving when trying to join it.

Any help is appreciated.

Hey @john8,

Happy to help! :slight_smile: Can you please share your Web SDK signature for a test meeting to developersupport@zoom.us, so I can debug it?

Thanks,
Tommy

Hi Tommy,

The signature is in both of the images above. Let me know if you need anything else.

Thanks

Hi Tommy,

Here is the error I am receiving

Any help is appreciated.

Thanks

John

Hey @john8,

After base64 decoding your signature it looks like you are generating it incorrectly:

Decoded, it should be in the following format:

jwtKey.meetingNumber.expiryTime.role.encryptedJwtSecret

Thanks,
Tommy

Hi

I have exactly the same issue, I think I am generating the signature wrong. Could you have a look at the code and potentially help me find the issue?

const timestamp = new Date().getTime() - 30000
const msg = Base64.encode(config.apiKey + config.meetingNumber + timestamp + config.role)
const hash = Base64.encode(CryptoJS.HmacSHA256(msg, API_SECRET).toString(CryptoJS.enc.Hex))
const signature = Base64.encode(`${config.apiKey}.${config.meetingNumber}.${timestamp}.${config.role}.${hash}`)

Hi, I just got this working then I was called off to do something else so the code may be a little sloppy but here are rough steps to get a token, then create, start and join a meeting. This is in ASP.NET MVC with C# and jQuery.

First, generate a token

static readonly char padding = { ‘=’ };

public static string GenerateToken(string apiKey, string apiSecret, string meetingNumber, string ts, string role)

{

string message = String.Format("{0}{1}{2}{3}", apiKey, meetingNumber, ts, role);

apiSecret = apiSecret ?? “”;

var encoding = new System.Text.ASCIIEncoding();

byte keyByte = encoding.GetBytes(apiSecret);

byte messageBytesTest = encoding.GetBytes(message);

string msgHashPreHmac = System.Convert.ToBase64String(messageBytesTest);

byte messageBytes = encoding.GetBytes(msgHashPreHmac);

using (var hmacsha256 = new HMACSHA256(keyByte))

{

byte hashmessage = hmacsha256.ComputeHash(messageBytes);

string msgHash = System.Convert.ToBase64String(hashmessage);

string token = String.Format("{0}.{1}.{2}.{3}.{4}", apiKey, meetingNumber, ts, role, msgHash);

var tokenBytes = System.Text.Encoding.UTF8.GetBytes(token);

return System.Convert.ToBase64String(tokenBytes).TrimEnd(padding);

}

}

Next, create a meeting. This is fetched in a .js file. The token passed in is the token created above. From the json, you can parse out the Meeting ID (id) and Meeting Password (password) for the new meeting and store it in the fields MeetingNumber and Password on the page.

public async Task CreateMeetingAsync(string token)

{

var stringContent = “{“topic”: “Test Meeting”,“type”: “1”,“timezone”: “America/Chicago”,“password”: “password”,“agenda”: “Test Agenda”,” +

““settings”: {“host_video”: “true”,“participant_video”: “false”,“cn_meeting”: “false”,“in_meeting”: “false”,“join_before_host”: “false”,” +

““mute_upon_entry”: “false”,“watermark”: “false”,“use_pmi”: “false”,“approval_type”: “0”,“registration_type”: “1”,“audio”: “both”,“auto_recording”: “none”}}”;

HttpClient client = new HttpClient();

client.BaseAddress = new Uri(“https://api.zoom.us/v2/users/yourZoom@emailAddress.com/meetings”);

client.DefaultRequestHeaders

.Accept

.Add(new MediaTypeWithQualityHeaderValue(“application/json”));//ACCEPT header

client.DefaultRequestHeaders.Add(“Authorization”, "Bearer " + token);

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, “meetings”);

request.Content = new StringContent(stringContent,

Encoding.UTF8,

“application/json”);//CONTENT-TYPE header

HttpResponseMessage response = new HttpResponseMessage();

await client.SendAsync(request)

.ContinueWith(responseTask =>

{

Console.WriteLine(“Response: {0}”, responseTask.Result);

response = responseTask.Result;

});

var json = response.Content.ReadAsStringAsync();

return Json(json);

}

Then you will need to generate an access token for the meeting id you just received. Again, this is fetched in the .js file. I store this in a field called MeetingToken on the page.

public ActionResult GetMeetingAccessToken(string meetingNumber)

{

String ts = (ToTimestamp(DateTime.UtcNow.ToUniversalTime()) - 30000).ToString();

string role = “1”;

var result = GenerateToken(apiKey, apiSecret, meetingNumber, ts, role);

return Json(result);

}

Now you should have all the info you need to join the meeting via ZoomMtg. Below is a snippet of code from the .js file, $(‘#Role’) is 1

function joinMeeting() {

meetConfig.apiKey = API_KEY;

meetConfig.signature = $(’#MeetingToken’).val();

meetConfig.userName = $(’#Name’).val();

meetConfig.passWord = $(’#Password’).val();

meetConfig.role = $(’#Role’).val();

meetConfig.meetingNumber = $(’#MeetingNumber’).val();

ZoomMtg.init({

leaveUrl: meetConfig.leaveUrl,

isSupportAV: true,

debug: true,

success: function (res) {

ZoomMtg.join({

signature: meetConfig.signature,

apiKey: meetConfig.apiKey,

meetingNumber: meetConfig.meetingNumber,

userEmail: meetConfig.userEmail,

userName: meetConfig.userName,

passWord: meetConfig.passWord,

success: function (res) {

console.log(‘success’);

},

error: function (res) {

console.log(‘error’);

console.log(res);

},

})

},

error: function (error) {

console.log(‘error’);

}

});

ZoomMtg.inMeetingServiceListener(‘onUserJoin’, function (data) {

console.log(‘inMeetingServiceListener onUserJoin’, data);

});

ZoomMtg.inMeetingServiceListener(‘onUserLeave’, function (data) {

console.log(‘inMeetingServiceListener onUserLeave’, data);

});

ZoomMtg.inMeetingServiceListener(‘onUserIsInWaitingRoom’, function (data) {

console.log(‘inMeetingServiceListener onUserIsInWaitingRoom’, data);

});

ZoomMtg.inMeetingServiceListener(‘onMeetingStatus’, function (data) {

// {status: 1(connecting), 2(connected), 3(disconnected), 4(reconnecting)}

console.log(‘inMeetingServiceListener onMeetingStatus’, data);

});

}

Hope this helps!

Thanks a lot. I just got it working by simply using the method already available in the API:

ZoomMtg.generateSignature(...)

Hey @sdk_testing,

I’m glad to hear that @john8’s post was helpful and that you were able to get it figured out. As always, feel free to reach out if you encounter any further issues or questions.

Thanks,
Max

hi… i used the sample code in PHP from zoom link https://marketplace.zoom.us/docs/sdk/native-sdks/web/build/signature to generate signature but gives me error message that " signatrue length error, 0 < length < 150" …

i tried this formula jwtKey.meetingNumber.expiryTime.role.encryptedJwtSecret
by doing this
$_sig = $api_key . “.” . $meeting_number . “.” . $time . “.” . $role . “.” . api_secret;** **return rtrim(strtr(base64_encode(sig), ‘+/’, '-’), ‘=’);
but i still get the same error
any help?

Hi qwakuaa,

Did you use the following to generate your signature?

function generate_signature ( $api_key, $api_secret, $meeting_number, $role){

	$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), '+/', '-_'), '=');
}

You can test if it is correct by decoding it here https://www.base64decode.org/

Thanks

working now… i changed return to echo

1 Like

Happy to hear you got it working @qwakuaa ! :slight_smile:

Thanks for your suggestion @john8 !

Thanks,
Tommy

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