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.
$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:
$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 :
{"reason":"Invalid authorization code","error":"invalid_grant"}
Thanks