# Need help with autorizations and token in PHP Curl

**URL:** <https://devforum.zoom.us/t/need-help-with-autorizations-and-token-in-php-curl/95313>\
**Category:** Authentication\
**Created:** [September 18, 2023, 3:20pm UTC](https://devforum.zoom.us/t/need-help-with-autorizations-and-token-in-php-curl/95313 "2023-09-18T15:20:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antho](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@Antho](https://devforum.zoom.us/u/Antho)\
**Post date:** [September 18, 2023, 3:20pm UTC](https://devforum.zoom.us/t/need-help-with-autorizations-and-token-in-php-curl/95313/1 "2023-09-18T15:20:28Z")

</div>

I’m lost with autorizations and tokens.  
I want to dynamically create meetings in PHP.

I found this code but I can’t test it because I’m stuck for the token.

```auto
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.zoom.us/v2/users/xxx/meetings",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\r\n \"agenda\": \"My Meeting\",\r\n \"default_password\": false,\r\n \"duration\": 60,\r\n \"password\": \"123456\"\r\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer {YOUR TOKEN HERE}",
    "Content-Type: application/json"
  ),
));

```

I’m not sure if I should use the OAuth or Server to Server OAuth app.  
I tried with client\_id and secret\_id from OAuth App, the code I get when I add app in Activation \> Add and the redirect url I put in App credentials:

```auto
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://zoom.us/oauth/token?grant_type=authorization_code&code=".$code."&redirect_uri=".$redirectUrl,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => $headers
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

The response is :

```auto
{"reason":"Invalid authorization code","error":"invalid_grant"}

```

Thanks

---

<div class="post-metadata">

**Author:** ![Antho](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@Antho](https://devforum.zoom.us/u/Antho)\
**Post date:** [September 19, 2023, 8:25am UTC](https://devforum.zoom.us/t/need-help-with-autorizations-and-token-in-php-curl/95313/4 "2023-09-19T08:25:41Z")

</div>

Sorry for the deleted post, I want to delete the topic but ther is a bug.

I found solution using Server to Server OAuth.
