[HELP] Server-to-Server oAuth Request

Hi,

I am trying to request an access token using Server-to-Server oAuth via PHP.

This is my code:

// The API endpoint for obtaining an access token
$token_endpoint = ‘/oauth/token’;

// The scope of the access token
$scope = 'scope:read:admin';

try {
    // Request an access token using the account_credentials grant type
    $response = $client->post($token_endpoint, [
        'headers' => [
            'Authorization' => 'Basic ' . base64_encode($client_id . ':' . $client_secret),
            'Content-Type' => 'application/x-www-form-urlencoded',
        ],
        'form_params' => [
            'grant_type' => 'account_credentials',
            'scope' => $scope,
        ],
    ]);

However I get the following error:

Client error: POST https://zoom.us/oauth/token resulted in a 400 Bad Request response: {“reason”:“Bad Request”,“error”:“invalid_request”}

When I change the grant type to “client_credentials” it returns me an access token?

Can anyone help?

Kind Regards.

Our application passes grant_type and account_id in the request body, and not scope. (See Internal apps (Server-to-server).) It probably won’t be significant, but we also specifically declare the character encoding: Content-Type: application/x-www-form-urlencoded; charset=utf-8

1 Like