Following the MercadoPago documentation ( link ) I get to the point where I need to obtain the user's credentials.
Previously the application was created and the e-mail was sent to the person from whom we need authorization.
At the time of requesting your credentials, MercadoPago returns:
{"message":"The redirect_uri does not match the original","error":"invalid_grant","status":400,"cause":[]}
The URL is the same as the one that was loaded in the creation of the application and the parameter that is passed. ( link )
$datos = array(
'client_id' => [CLIENT_ID],
'client_secret' => [CLIENT_SECRET],
'grant_type' => 'authorization_code',
'code' => [CODIGO_OBTENIDO_DE_GET],
'redirect_uri' => 'http://mi-url'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.mercadopago.com/oauth/token");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($datos));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close ($ch);
var_dump($output);
What can I be doing wrong?