# Server to server oauth issues

**URL:** <https://devforum.zoom.us/t/server-to-server-oauth-issues/74246>\
**Category:** API and Webhooks\
**Created:** [August 15, 2022, 4:54pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246 "2022-08-15T16:54:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![colin1](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@colin1](https://devforum.zoom.us/u/colin1)\
**Post date:** [August 15, 2022, 4:54pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246/1 "2022-08-15T16:54:05Z")

</div>

Hi,

This has been posted previously but I am still experiencing the same issue.  
I am making a call to [https://zoom.us/oauth/token?grant\_type=account\_credentials&account\_id=](https://zoom.us/oauth/token?grant_type=account_credentials&account_id=)  
I supply my account id in the URL.  
I am POST the following headers:  
Authorization: Basic '. base64\_encode(“$clientid:$secret”)

Which has been talked about on here many times.  
I have enabled the permissions on my account for server-to-server.

However, i am still getting the following response:

{“reason”:“Invalid client\_id or client\_secret”,“error”:“invalid\_client”}

I am going slightly mad with this…please help 🙂

Regards  
Colin

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [August 15, 2022, 9:20pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246/2 "2022-08-15T21:20:09Z")

</div>

Hi @collin.taylor1 , what are you putting here?

> [@colin1](#):
>
> Authorization: Basic '. base64\_encode(“$clientid:$secret”)

It should be something like this: `Basic Q2xpZW50X0lEOkNsaWVudF9TZWNyZXQ=`

Note, above clientId:secret just for demo purposes.

---

<div class="post-metadata">

**Author:** ![colin1](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@colin1](https://devforum.zoom.us/u/colin1)\
**Post date:** [August 16, 2022, 7:34am UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246/3 "2022-08-16T07:34:15Z")

</div>

Hi

Thanks for replying.  
I’m getting the client id and secret from the portal, the resulting base64 encoded string is similar to what you are suggesting.  
I have seen previous answers to this question in other posts and have done every solution they have suggested etc.

Thanks again for any help.

---

<div class="post-metadata">

**Author:** ![colin1](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@colin1](https://devforum.zoom.us/u/colin1)\
**Post date:** [August 16, 2022, 3:28pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246/4 "2022-08-16T15:28:29Z")

</div>

Interesting,

I have just been able to generate a token by using Postman but my PHP code is not working.  
Do you have any examples of server-to-server auth PHP code?

---

<div class="post-metadata">

**Author:** ![colin1](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@colin1](https://devforum.zoom.us/u/colin1)\
**Post date:** [August 16, 2022, 3:46pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246/5 "2022-08-16T15:46:29Z")

</div>

Sorted it.

For anyone elses reference:

```auto
$url = "https://zoom.us/oauth/token?grant_type=account_credentials&account_id=" . $accountid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(        
    'grant_type' => 'client_credentials', # https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/        
    'scope' => $scope,  
)));

$headers[] = "Authorization: Basic " . base64_encode($clientid . ":" . $secret);
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$data = curl_exec($ch);
$auth = json_decode($data, true); // token will be with in this json

var_dump( $auth );

```

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [August 16, 2022, 7:27pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246/6 "2022-08-16T19:27:00Z")

</div>

Hi @colin1 ,

Thank you for sharing this code sample and glad it is resolved!

Best,  
Gianni

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [August 20, 2023, 11:03am UTC](https://devforum.zoom.us/t/server-to-server-oauth-issues/74246/7 "2023-08-20T11:03:11Z")

</div>

This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.
