Umair Ansari
Umair Ansari

Reputation: 1

Rest API of neteller show invalid client Error

$username = 'MerchantXYZ';
$password = 'B81dff9bb4020a89e8ac44cdfdcecd702151182fdc952272661d290ab2e5849e31bb03deede';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, "https://api.neteller.com/v1/oauth2/token?grant_type=client_credentials");
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Cache-Control:no-cache"));
curl_setopt($curl, CURLOPT_POSTFIELDS, array("scope"=>"default"));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$serverOutput = curl_exec($curl);
echo $serverOutput;

I am using this code but every time show me { "error": "invalid_client" } this message. I have checked my API and IP address, everything is perfect.

Upvotes: 0

Views: 1820

Answers (1)

SimeonUzunov
SimeonUzunov

Reputation: 209

There are 4 reasons why you may get { "error": "invalid_client" } when trying to get a token.

  1. You are using client_id + client_secret from your test account on the production environment or vice versa.
  2. Your client_id or client_secret values are wrong.
  3. The IP address from which your application is making outgoing requests is not white-listed in your merchant account.
  4. You are not sending the Authorization header properly.

Check points 1) - 3); From your example I can see you can rule out point 4) as a possible reason.

Also, you don't need this line:

curl_setopt($curl, CURLOPT_POSTFIELDS, array("scope"=>"default"));

According to the documentation you shouldn't post anything in the body of the request when getting a token. Where did you get this example from?

Upvotes: 3

Related Questions