What am i doing wrong here. Shows me Signature is invalid when try to start the meeting,
// Method to generate a JWT signature for Zoom Meeting
public String generateJWT(String meetingNumber, String role) {
long iat = System.currentTimeMillis() / 1000 - 30; // Current time in seconds minus 30 seconds for iat
long exp = (iat + 60 * 60); // Expiration time for JWT (1 hour)
long tokenExp = exp + 60 * 60; // Token expiration time (1 hour)
// Construct the payload for the JWT
String payload = String.format("{"
+ "\"appKey\": \"%s\","
+ "\"mn\": \"%s\","
+ "\"role\": \"%s\","
+ "\"iat\": %d,"
+ "\"exp\": %d,"
+ "\"tokenExp\": %d"
+ "}", clientId, meetingNumber, role, iat, exp, tokenExp);
// Generate the JWT signature using HMAC SHA256
return HmacSHA256(payload, clientSecret);
}
// Method to generate the JWT signature using HMAC SHA256
private String HmacSHA256(String payload, String key) {
try {
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);
byte[] bytes = sha256_HMAC.doFinal(payload.getBytes());
return Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}