I am trying to consume a service that I exposed from a project that I have in c #, the problem is that when consuming the service from php I get the following error. {"error":"unsupported_grant_type"}
Code:
function __construct() {
# data needs to be POSTed to the Play url as JSON.
# (some code from http://www.lornajane.net/posts/2011/posting-json-data-with-php-curl)
$data = array("grant_type" => "password", "username" => "Administrador", "password" => "xxxx");
$data_string = json_encode($data);
print_r($data_string);
$ch = curl_init('https://integraciones.intergrupo.com/rest/oauth/token');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded')
);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
echo $result; // Outputs the JSON decoded data
}