简体   繁体   中英

Neteller REST API gives an error

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 (eg, 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.

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).

It might be a header issue.

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

This should probably solve it:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM