# \[HELP\] Server-to-Server oAuth Request

**URL:** <https://devforum.zoom.us/t/help-server-to-server-oauth-request/88564>\
**Category:** Authentication\
**Tags:** server-to-server\
**Created:** [May 17, 2023, 2:27pm UTC](https://devforum.zoom.us/t/help-server-to-server-oauth-request/88564 "2023-05-17T14:27:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tradersuniversity](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tradersuniversity/32/48607_2.png) [@tradersuniversity](https://devforum.zoom.us/u/tradersuniversity)\
**Post date:** [May 17, 2023, 2:27pm UTC](https://devforum.zoom.us/t/help-server-to-server-oauth-request/88564/1 "2023-05-17T14:27:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MultiplayerSession](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/multiplayersession/32/66446_2.png) [@MultiplayerSession](https://devforum.zoom.us/u/MultiplayerSession)\
**Post date:** [May 17, 2023, 4:39pm UTC](https://devforum.zoom.us/t/help-server-to-server-oauth-request/88564/2 "2023-05-17T16:39:12Z")

</div>

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