Server to server oauth issues


This has been posted previously but I am still experiencing the same issue.
I am making a call to
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 :slight_smile:


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

It should be something like this: Basic Q2xpZW50X0lEOkNsaWVudF9TZWNyZXQ=

Note, above clientId:secret just for demo purposes.


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.


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?

Sorted it.

For anyone elses reference:

$url = "" . $accountid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(        
    'grant_type'    => '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 );

Hi @colin1 ,

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