api/oauth/access_token: "message": "Client authentication failed"

I’m trying to set up SuiteCRM authentication through OAuth2, but I’m not getting it.
Code below:

$ch = curl_init();
$header = array(
    'Content-type: application/vnd.api+json',
    'Accept: application/vnd.api+json'
$postStr = json_encode(array(
    'grant_type' => 'client_credentials',
    'client_id' => 'xxxxxxxxxxxxxxxxxxxxxx',
    'client_secret' => 'client_secret',
    'scope' => 'standard:create standard:read standard:update standard:delete standard:delete standard:relationship:create standard:relationship:read standard:relationship:update standard:relationship:delete'

$url = 'https://xxxxxxxxxxxxxxxxxxxxxx/api/oauth/access_token';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$output = curl_exec($ch);
$response = json_decode($output, true);	

var_dump( $response );

Return: array(2) { ["error"]=> string(14) "invalid_client" ["message"]=> string(28) "Client authentication failed" } 

Can someone help me?


Hi, welcome to the Forums!

Please always use “code” tags around code, otherwise some brackets get removed.

And state your version of SuiteCRM and of the API you’re using (is it v8?).

Anyway, I won’t be able to answer your question, I don’t know enough about the API, but I’m hoping someone else might answer.

1 Like

SuiteCRM Version 7.10.6
Sugar Version 6.5.25 (Build 344)
PHP Version 7.0.30-0ubuntu0.16.04.1
Apache 2.0 Handler

SuiteCRM and ERP are inside the same server.

In the next source code post I’ll put the tags. Sorry.

1 Like

Can you try upgrading to 7.10.7? The v8 API is new and I know there were several bugfixes.

1 Like

The Version was been update.

Versão 7.10.7
Sugar Versão 6.5.25 (Compilaçāo 344)

I have done all the procedures that are listed in the https://docs.suitecrm.com/developer/api/version-8/configure-authentication/ but continue with the same error.

array(2) { ["error"]=> string(14) "invalid_client" ["message"]=> string(28) "Client authentication failed" } 

HTTPS/SSL: Let’s Encrypt

I have not found the / api / oauth /

I know less than you about API, but I managed to steal a minute from one of the API developers in a Chat and he said

I also hope this is understandable :slight_smile:

1 Like