Does anybody know how to translate the following curl command into ajax/ xmlhttpsrequest?
curl -d "[email protected]&client_secret=123456789&password=pwdgoeshere&grant_type=password&client_id=ReallyLongClientIDGoesHere" -H "Accept: application/json" https://login.salesforce.com/services/oauth2/token
I would like to achieve something like the following 2 examples , but my code doesn't work:
1)
var req = new XMLHttpRequest();
req.open( "POST", "https://login.salesforce.com/services/oauth2/token", true);
req.setRequestHeader('Accept', 'application/json');
req.send();
2)
$.ajax({
url: myUrl,
headers: myHeaders,
type: 'POST',
processData: false,
contentType: false,
}).complete(function ( data ) {
console.log(data.responseText);
});