Created
October 4, 2021 13:53
-
-
Save Stoltze/636d0947fb98ef55a1acc46eb70c05fd to your computer and use it in GitHub Desktop.
Vanilla PHP JWT Token Generator for Zoom API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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