When I do a request from curl it works, but when I try to do the same thing from AngularJS it returns:
XMLHttpRequest cannot load https://www.example.com/oauth/token Response for preflight is invalid (redirect)
This is the curl query:
curl -v https://www.example.com/oauth/token -d "client_id=1&client_secret=1&code=1"
This is my AngularJS code:
$http({
method: "post",
url: "https://www.example.com/oauth/token",
data: "client_id=" + clientID + "&client_secret=" + clientSecret + "&code=" + requestToken,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': '*'
}
})
.success(function (data) {
console.log(data);
// deferred.resolve(data);
})
.error(function (data, status) {
console.log(data);
//deferred.reject("Problem authenticating");
})
.finally(function () {
// setTimeout(function () {
// browserRef.close();
// }, 10);
});
What can be the problem?
Also, I tried all the solution from the possible duplicate page, and they didn't work.
I tried to do the request on a local nodejs webserver and it returns the result. From the client I make the request to the nodejs webserver, and I have the same issue, even though the request is on http.