Is it possible to convert the given curl code into a JavaScript post request that will function effectively in all browsers?
curl https://connect.stripe.com/oauth/token \
-d client_secret=sk_test_f7PKXx5NRBFG5r41nTrPT7qB \
-d code="{AUTHORIZATION_CODE}" \
-d grant_type=authorization_code
Upon conducting some research and analyzing this response Convert command curl to javascript , I have discovered that I could execute the request in the following manner:
$.ajax({
url: "https://connect.stripe.com/oauth/token",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
type: 'POST',
dataType: 'json',
contentType: 'application/json',
processData: false,
success: function (data) {
console.log(JSON.stringify(data));
},
error: function(){
console.log(error)
}
});
But how can I include the client_secret, code, and grant_type parameters within this JavaScript post request?