Hello All,
I need php script for generating JWTKey for zoom API v2 integration.
Can someone please provide me the script and their supporting files.
Thank you
Hello All,
I need php script for generating JWTKey for zoom API v2 integration.
Can someone please provide me the script and their supporting files.
Thank you
Hey @Dora_Reddy,
See the JWT Token generation sample PHP code here:
https://marketplace.zoom.us/docs/guides/auth/jwt#sample-code
Thanks,
Tommy
Thanks @tommy for the reply.
From the link i see PHP code below and it is used for Active Users from Zoom not for generateJWT token.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer 39ug3j309t8unvmlmslmlkfw853u8",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Actually Iâm expecting script for generating JWT token like below ( I donât have complete script I found below piece of code in some other thread)
private function generateJWTKey() {
$key = $this->zoom_api_key;
$secret = $this->zoom_api_secret;
$token = array(
âissâ => $key,
âexpâ => time() + 3600 //60 seconds as suggested
);
return JWT::encode( $token, $secret );
}
Hey @Dora_Reddy,
Ah true, apologies. You can see sample PHP code and libraries for generating JWT tokens here:
Thanks,
Tommy
@tommy Iâm facing difficulty in generating JWT token through PHP Code.
So Iâm generating JWT token from JWT app provided at marketplace.zoom.us below
https://marketplace.zoom.us/develop/apps/E******************n/credentials
by having Expiration Time for a longer period of 2 years and saving the JWT token in our database.
Later on using the saved JWT token whenever i use Zoom API for creating meetings.
Will this work?
Hey @Dora_Reddy,
That will work, but it is more secure to generate the JWT Token for a shorter amount of time, each time you want to use it.
Did none of the helper libraries work from jwt.io?
Thanks,
Tommy
@tommy Thanks for the reply. I looked into https://jwt.io/ but it had many libraries. Iâm confused to pick the correct one suitable for my requirement.
In this post Help with api create meeting with php @mike1 posted below code for generating JWT but it didnât have full code like JWT::encode function. Looking for full working code
//function to generate JWT
private function generateJWTKey() {
$key = $this->zoom_api_key;
$secret = $this->zoom_api_secret;
$token = array(
âissâ => $key,
âexpâ => time() + 3600 //60 seconds as suggested
);
return JWT::encode( $token, $secret );
}
Did you ever figure this out? Iâm just now trying to make this work, but none of the libraries match up well to the Zoom API documentation.
Still i didnât found any solution. Let me know if you find any. Looking for help.
Yes, that is the one that Iâm trying to use, but to no avail.
@laurinkeithdavis Can you provide a sample of how youâre trying to do it?
You can find a well-written write up here as well: https://www.sitepoint.com/php-authorization-jwt-json-web-tokens/
I donât know that posting any example I have so far would be helpful. Iâm just trying to make the connection, I canât even figure out what the parameters are supposed to be or how I generate the token.
Read that one as well, and thanks, but still canât figure it out. Is there not a working example of using the Zoom API in PHP? The one in the docs does not make sense (https://marketplace.zoom.us/docs/guides/auth/jwt) - what goes where in that sample?? What is the âBearerâ?
@laurinkeithdavis, I found the Zoom documentation lacking as well. Hereâs an example of generating the token with firebase/php-jwt and GuzzleHttp (see code below).
This will generate a JWT token with a 5 second lifespan. Then, it will use the token to make a request to Zoomâs API with GuzzleHttp and list users on the account.
$api_secret = âXXXXXXâ;
$api_key = âXXXXXXâ;
$payload = array(
âissâ => $api_key,
âexpâ => (time() + 5)
);
$jwt = JWT::encode($payload, $api_secret);
$client = new \GuzzleHttp\Client([âheadersâ => [âauthorizationâ => 'Bearer '.$jwt]]);
$response = $client->request(
âGETâ,
âhttps://api.zoom.us/v2/usersâ
);
return json_decode($response->getBody(), true);
Thanks for providing a solution @andrew4!
@laurinkeithdavis let me know if this helps!
As for what the âBearerâ is, that just letâs the Zoom API know what kind of authentication to expect. Here is the request header you want to provide when making requests to the Zoom API:
{ "Authorization": "Bearer JWT_TOKEN_HERE" }
We will work on improving our JWT docs as soon as possible.
-Tommy
Iâve also found this one aspect to be very lacking in documentation. All the documentation that Iâve found is way over complicated. I just need to generate a JWT on the fly before each API call. I thought I remember seeing a Postman sample embedded in a webpage to generate the JWT but now I canât find that.
I would love to see the curl code to generate a JWT in a format like below. Iâm initiating everything from Filemaker so if I have the below format I can take from there.
curl --request GET
âurl âhttps://api.zoom.us/v2/users?status=active&page_size=30&page_number=1â
âheader âauthorization: Bearer { your_token }â
âheader 'content-type: application/json
Thanks!
Hey @FutureX,
Thanks for your feedback on our docs, we will work on making it more clear.
You can generate a test JWT Token on your JWT App Credentials page in the Marketplace.
Here are the JWT generation docs with a link to see libraries we recommend:
https://marketplace.zoom.us/docs/guides/auth/jwt
Thanks,
Tommy
Thanks for the response but thatâs not what Iâm looking for. I doing the credential generation from within Filemaker so itâs a basic URL call but I just need to see how the CURL is formatted similar to the sample in my last post.
Thanks!
Hey @FutureX,
Do you mean like this?
curl --request GET
âurl 'https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1'
âheader 'authorization: Bearer JWT_TOKEN_HERE'
âheader 'content-type: application/json'
Thanks,
Tommy