I am trying to make an API call in Ajax, here it is :
$.ajax({
method: "POST",
url: "https://login.salesforce.com/services/oauth2/token",
crossDomain: true,
data: "grant_type=password" +
"&client_id=" + CLIENTID +
"&client_secret=" + CLIENTSECRET +
"&username=" + USERNAME +
"&password=" + PASSWORD,
dataType: 'jsonp',
success: function (data) {
console.log(data);
},
error: function (err) {
console.log(err);
}
});
But when I try it, I got a console error :
jquery.min.js:2 GET https://login.salesforce.com/services/oauth2/token?callback=jQuery33100... net::ERR_ABORTED 400 (Bad Request)
What am I doing wrong? I tried in postman with the same info and i got a status 200