Skip to content

Instantly share code, notes, and snippets.

@Stoltze
Created October 4, 2021 13:53
Show Gist options
  • Save Stoltze/636d0947fb98ef55a1acc46eb70c05fd to your computer and use it in GitHub Desktop.
Save Stoltze/636d0947fb98ef55a1acc46eb70c05fd to your computer and use it in GitHub Desktop.
Vanilla PHP JWT Token Generator for Zoom API
$api_key = '[APY KEY]';
$api_secret = '[API SECRET]';
$expiration = time() + 60; //set to 1 minute, for security reasons
$h_array = [
'alg' => "HS256"
];
$p_array = [
'aud' => null,
'iss' => $api_key,
'exp' => $expiration,
'iat' => time()
];
$headers = json_encode($h_array);
$payload = json_encode($p_array);
$headers_encoded = base64_encode($headers);
$payload_encoded = base64_encode($payload);
$signature = hash_hmac('sha256',$headers_encoded . "." . $payload_encoded,$api_secret,true);
$signature_encoded = base64_encode($signature);
//build and return the token
$token = $headers_encoded . "." . $payload_encoded . "." . $signature_encoded;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment