HTTP 404 bad request for oAuth token
I have html page to get email and password from user and i want to send these criedentials to this url (https://oauth.wildapricot.org/auth/token) with the help of ajax request. i am getting bad request error from server. my request is $.ajax({
type: 'POST',
url: 'https://oauth.wildapricot.org/auth/token',
data: "grant_type=password&username=testim@test.com&password=123456&scope=auto",
dataType: "text",
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
xhrFields: {
withCredentials: true
},
//crossDomain: true,
headers: {
'Authorization': "Basic " + window.btoa(settings.clientId + ':' + settings.clientSecret),
"Content-Type": "application/json"
},
//beforeSend: function (xhr) {
//},
success: function (result) {
var token = result;
},
//complete: function (jqXHR, textStatus) {
//},
error: function (req, status, error) {
debugger;
alert(error);
}
});
please can me figure out where i am wrong.
-
I see 2 problems here:
1. auth service does not support CORS, so it can't work from JS
2. Contradictory content type in request params and in headersPlease, in future attach request content instead of JS code and use gist.com to avoid code formatting issues.