Greetings,
I am trying to use the payment market api connect, but I have problems getting my user's credentials. I already configure the url of my application in the paid market, by redirecting the user to the paid market page so that he can enter his credentials, mercadopago correctly sends the authorization token to my node.js server, but already with the said token to request the credentials and always shows me the same error:
{"name":"MercadoPagoError","message":"{\"message\":\"The redirect_uri does not match the original\",\"error\":\"invalid_grant\",\"status\":400,\"cause\":[]}","stack":"Error\n at new MercadoPagoError (/user_code/node_modules/mercadopago/lib/mercadopago.js:16:16)\n at Request._callback (/user_code/node_modules/mercadopago/lib/mercadopago.js:527:22)\n at Request.self.callback (/user_code/node_modules/mercadopago/node_modules/request/request.js:188:22)\n at emitTwo (events.js:106:13)\n at Request.emit (events.js:191:7)\n at Request.<anonymous> (/user_code/node_modules/mercadopago/node_modules/request/request.js:1171:10)\n at emitOne (events.js:96:13)\n at Request.emit (events.js:188:7)\n at IncomingMessage.<anonymous> (/user_code/node_modules/mercadopago/node_modules/request/request.js:1091:12)\n at IncomingMessage.g (events.js:291:16)","statu
The code I use on the server side is the following:
// Create the request
const mpCredentialsRequest = {
"uri": "/oauth/token",
"params": {
"client_secret": ACCESS_TOKEN,
"grant_type": "authorization_code",
"code": authorizationCode,
"redirect_uri": url
},
"authenticate": false
};
//Requesting the client credentials
mercadopago.post(mpCredentialsRequest).then(function(result) {
console.log('result.status = ${result.status}');
if(result.status == 200){
const credentials = result.response;
processCredentials(userId, credentials, req, res);
}
}).catch((error) => {
console.log(error);
res.send(500, error);
});
In the url I put the same one that I have configured in the paid market.
Thanks for the help.