2
votes

I've been working with neteller rest api and I came across an issue. I am receiving this response: { "error": "invalid_client" }

My code is

$username = '**********';
$password = '*********************************';
$curl = curl_init();

curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, "https://test.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_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$serverOutput = curl_exec($curl);

echo $serverOutput;

The documentation says: Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method). The authorization server MAY return an HTTP 401 (Unauthorized) status code to indicate which HTTP authentication schemes are supported. If the client attempted to authenticate via the "Authorization" request header field, the authorization server MUST respond with an HTTP 401 (Unauthorized) status code and include the "WWW-Authenticate" response header field matching the authentication scheme used by the client.

But I'm not sure I completely understand this..

I've tried every possible solution that I found online, but nothing works.. Is there something wrong with my CURL?

Thanks for your time.

3

3 Answers

3
votes

You get this error message if your IP is blocked. Log in to the Neteller TEST merchant site (test.merchant.neteller.com). You will need to email support to get a user if you haven't already. Go to Developer / API Settings and check that the APIs are enabled and that your IPs are added.

You need to do the same thing for production (merchant.neteller.com).

0
votes

It might be a header issue.

Try this as your content type: application/x-www-form-urlencoded

0
votes

This should probably solve it:

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