MercadoPago Applications does not return user credentials

3

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?

    
asked by Ignacio Cuppi 26.01.2017 в 18:04
source

1 answer

1

This error occurs only when the redirect_uri of the application does not match the one sent in the url where the user enters.

The most likely thing is that you are missing a / at the end or some similar detail, but only occurs in this case.

Example: If in the application you configured in redirect_url link , but in the url you use link , this one is going to fail.

All the information of your application can be seen by entering the following link and clicking on "< em> Details "to view or" Edit "to edit.

    
answered by 31.01.2017 в 20:39