Hello! I'm making cURL request to neteller API and it returns 401 not authorized. My IP is whitelisted in neteller test account.
I have the following code:

        $url = 'https://test.api.neteller.com/v1/oauth2/token;
        $clientId = NETELLER_CLIENT_ID;
        $clientSecret = NETELLER_CLIENT_SECRET;
        $grantType = 'grant_type=client_credentials';
        $curl = curl_init($url); 
        curl_setopt($curl, CURLOPT_POST, true); 
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_USERPWD,  $clientId.":".$clientSecret);
        curl_setopt($curl, CURLOPT_HEADER, false); 
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
        curl_setopt($curl, CURLOPT_POSTFIELDS, $grantType); 
        $response = curl_exec($curl);
        if (curl_error($curl)) {
            throw new \Exception('System error. Can not get neteller token');
        $jsonResponse = json_decode($response, true); // Convert the result from JSON format to a PHP array
        return $jsonResponse;

But when I run cURL request in command line in the following way, it returns access token:

curl -XPOST -H "Cache-Control:no-cache"   -H "Content-Type:application/json"   --user NETELLER_CLIENT_ID:NETELLER_CLIENT_SECRET   'https://test.api.neteller.com/v1/oauth2/token?grant_type=client_credentials'

Where I am wrong in my PHP code, as command line request returns access token but using php code returns 'invalid client'? Thansk!

1 Year
Discussion Span
Last Post by iveto89

I have tried this:

 $headers = array(
        'Authorization: Basic '. $clientId.':'.$clientSecret,

 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

but still the same result?
How should be cURL request in PHP to be the same as the cURL request from command line? I have tried many ways.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.