# PHP & JWT - Basic instructions

**URL:** <https://devforum.zoom.us/t/php-jwt-basic-instructions/15879>\
**Category:** API and Webhooks\
**Created:** [May 3, 2020, 5:01pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879 "2020-05-03T17:01:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurinkeithdavis](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/laurinkeithdavis/32/7533_2.png) [@laurinkeithdavis](https://devforum.zoom.us/u/laurinkeithdavis)\
**Post date:** [May 3, 2020, 5:01pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/1 "2020-05-03T17:01:24Z")

</div>

I’m an experienced PHP developer but have only a little work with RESET API’s and none with JWT. For the life of me, I cannot figure out to get the JWT token without having to manually create it using the marketplace UI.

I’ve read numerous posts on this site, to no avail.

---

<div class="post-metadata">

**Author:** ![michael.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.zoom/32/37213_2.png) [@michael.zoom](https://devforum.zoom.us/u/michael.zoom)\
**Post date:** [May 5, 2020, 11:07pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/2 "2020-05-05T23:07:55Z")

</div>

Hi @laurinkeithdavis, have you tried using one of the recommended libraries on [JWT.io](https://jwt.io/#libraries-io)?

We also have sample PHP code on our [JWT docs](https://marketplace.zoom.us/docs/guides/auth/jwt), are you able to add this token generation to your requests?

---

<div class="post-metadata">

**Author:** ![laurinkeithdavis](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/laurinkeithdavis/32/7533_2.png) [@laurinkeithdavis](https://devforum.zoom.us/u/laurinkeithdavis)\
**Post date:** [May 6, 2020, 11:35am UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/3 "2020-05-06T11:35:57Z")

</div>

Yes, tried [GitHub - firebase/php-jwt: PHP package for JWT](https://github.com/firebase/php-jwt), but there things in the Zoom API documentation that do not match up. For example:

[https://marketplace.zoom.us/docs/guides/auth/jwt](https://marketplace.zoom.us/docs/guides/auth/jwt)

> `iss` , the issuer of the token, is your API Key.
> 
> `exp` is the expiration timestamp of the token in seconds since Epoch (unix epoch time).
> 
> ```auto
> {
> "iss": "API_KEY",
> "exp": 1496091964000
> }
> 
> ```

However, in the firebase/php-jwt docs:

> $payload = array(  
> “iss” =\> “[http://example.org](http://example.org)”,  
> “aud” =\> “[http://example.com](http://example.com)”,  
> “iat” =\> 1356999524,  
> “nbf” =\> 1357000000  
> );

Why does the Zoom API documentation state “iss” is “API\_KEY” and not a URL? I’ve tried using various examples, but I can’t get it to work.

---

<div class="post-metadata">

**Author:** ![samly](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@samly](https://devforum.zoom.us/u/samly)\
**Post date:** [May 6, 2020, 1:01pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/4 "2020-05-06T13:01:21Z")

</div>

Every REST API that uses a JWT may have their own structure for the payload. What is given by the library is just an example of a common format. Zoom tells you what format it needs, so just use that format, regardless of if the issuer parameter being used for the API key vs a URL.

I’ve not tested this exact example myself, but it should go something like:

```php
/* Based on the firebase/php-jwt docs with Zoom's specifications */
use \Firebase\JWT\JWT;

$key = "my api secret here";
$payload = array(
    "iss" => "my api token here",
    "exp" => time()+36000, // expire in 10 hours
);

$jwt = JWT::encode($payload, $key, 'HS256'); // use the secret to sign the payload with a specific hashing algorithim

print_r($jwt); // This is your JWT token. Paste it into https://jwt.io for verification that it is valid. 

/* Now we can talk to Zoom directly using Zoom's PHP example */

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1", //This is the Zoom API endpoint you'd hit to get a list of active users. 
  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 {$jwt}", // You provide your JWT token in the Authorization header. 
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

```

Alternatively, if you do not want to use the `firebase/php-jwt` library, you can generate the token yourself. There’s an example from another user here that works with minimal modification: [JWT token creation](https://devforum.zoom.us/t/jwt-token-creation/15783/2)

---

<div class="post-metadata">

**Author:** ![michael.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.zoom/32/37213_2.png) [@michael.zoom](https://devforum.zoom.us/u/michael.zoom)\
**Post date:** [May 7, 2020, 8:13pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/5 "2020-05-07T20:13:40Z")

</div>

Thanks for sharing this @samly!! Hope this helps @laurinkeithdavis!

---

<div class="post-metadata">

**Author:** ![laurinkeithdavis](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/laurinkeithdavis/32/7533_2.png) [@laurinkeithdavis](https://devforum.zoom.us/u/laurinkeithdavis)\
**Post date:** [May 10, 2020, 6:54pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/6 "2020-05-10T18:54:58Z")

</div>

Yes, that works, thanks!

---

<div class="post-metadata">

**Author:** ![laurinkeithdavis](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/laurinkeithdavis/32/7533_2.png) [@laurinkeithdavis](https://devforum.zoom.us/u/laurinkeithdavis)\
**Post date:** [May 10, 2020, 7:12pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/7 "2020-05-10T19:12:50Z")

</div>

Well, thanks for the help everyone, but could have saved myself a lot of time if I had realized that the API endpoint I wanted to use was for Business plans only (I have a Pro - this is not for a business, but for personal use).

---

<div class="post-metadata">

**Author:** ![michael.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.zoom/32/37213_2.png) [@michael.zoom](https://devforum.zoom.us/u/michael.zoom)\
**Post date:** [May 13, 2020, 7:56pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/8 "2020-05-13T19:56:15Z")

</div>

Hi @laurinkeithdavis, which API are you using? All APIs are available to all users, but the feature will have to be available to your account. For example, if you don’t have Cloud Recording enabled for the user, there will be no data to access via Cloud Recording APIs.

---

<div class="post-metadata">

**Author:** ![laurinkeithdavis](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/laurinkeithdavis/32/7533_2.png) [@laurinkeithdavis](https://devforum.zoom.us/u/laurinkeithdavis)\
**Post date:** [May 15, 2020, 8:34pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/9 "2020-05-15T20:34:43Z")

</div>

> **[List Meeting Participants - Dashboards - Zoom API - API Reference](https://marketplace.zoom.us/docs/api-reference/zoom-api/dashboards/dashboardmeetingparticipants)**
>
> Get a list of participants from live or past meetings.
> If you do not provide the type query parameter, the default value will be set to live and thus, y...

I wish there was a way to get the business options without having to buy 10 licenses.

---

<div class="post-metadata">

**Author:** ![michael.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.zoom/32/37213_2.png) [@michael.zoom](https://devforum.zoom.us/u/michael.zoom)\
**Post date:** [May 18, 2020, 7:31pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/10 "2020-05-18T19:31:46Z")

</div>

Hi @laurinkeithdavis, I understand the benefit and the blockage that plans require. Could you share this feedback to our product team?

> **[Video Conferencing, Web Conferencing, Webinars, Screen Sharing](https://zoom.us/feed)**
>
> Zoom is the leader in modern enterprise video communications, with an easy, reliable cloud platform for video and audio conferencing, chat, and webinars across mobile, desktop, and room systems. Zoom Rooms is the original software-based conference...

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 9:22pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/11 "2020-08-21T21:22:50Z")

</div>


