Neteller REST API gives an error

2019-07-18 12:58发布

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.

标签: rest
3条回答
啃猪蹄的小仙女
2楼-- · 2019-07-18 13:41

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

查看更多
别忘想泡老子
3楼-- · 2019-07-18 13:42

This should probably solve it:

$data = array("scope" => "default");
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
查看更多
Emotional °昔
4楼-- · 2019-07-18 13:45

It might be a header issue.

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

查看更多
登录 后发表回答