Issue with Zoom API - Migration from JWT to Server-to-Server OAuth - PHP cUrl -code":200,"message":"Account does not enabled REST API."

Hi,

I’m trying to migrate our PHP Curl code to a server-to-server OAuth zoom app.

I’m able to get an access token but once I want to get infos about a meeting I got this message:

code":200,“message”:“Account does not enabled REST API.”

Same message if I use postman.

Here is an example of my PHP Code to get a meeting:

                      $webinar_zoom_id =  str_replace(' ', '', $webinar_zoom_id);

                        $curl = curl_init();
                        curl_setopt_array($curl, array(  
                            CURLOPT_URL => https://api.zoom.us/v2/meetings/.$webinar_zoom_id,   
                            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 ".$tokenV2."",
                                "cache-control: no-cache"
                            ),
                        ));
                         
                        $response = curl_exec($curl);
                        //var_dump($response);
                        $err = curl_error($curl);
                         
                        curl_close($curl);                        
                         
                        if ($err) {
                          echo "cURL Error #:" . $err;
                        } else {
                          $responseDecode = json_decode($response);
                        }

Could you help me to solve this issue please ?

Thanks a lot for your help.

Hey, I ran into this when starting out too! I think the issue is the original bearer token - make sure to request “account_credentials” via the “grant_type” parameter

1 Like

Hi @training6 ,

Is this the postman link from our workspace you used? Postman

Please let us know if that helps resolve!

Hi, thanks a lot for your help.

Here my code to get token:

$url = 'https://zoom.us/oauth/token';
	$data = array(
       'grant_type' => 'account_credentials'
    );
    
    $headers = array(
        'Authorization: Basic '. base64_encode($zoomAPIKey.":".$zoomSecretKey)
    );
    
    $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    
    if(curl_errno($curl)) {
        echo 'Curl error: ' . curl_error($curl);
    }
    
    curl_close($curl);

now i have bad request message (i changed client_credentials to account_credentials)

What do I have to change ?

A request for account_credentials requires an account_id in the URL, and a ClientID/ClientSecret in the request itself: " To use account credentials to get an access token for your app, call the Zoom OAuth token API with the account_credentials grant_type , your account_id , and your client ID and client secret, base64 encoded (encode your client ID and client secret with a colon between them, e.g. client_id:client_secret )."

By the way, it’s far easier to create/compose these requests using Postman, or if you’re sold on just PHP, something like Guzzle.

Hi,

Thanks a lot, it works now, I got the right token and can access method I want :slight_smile:

Big thank you both of you!

1 Like

Glad this is resolved! Thank you everyone!