Following the Stack Apps documentation Authentication (explicit) section I crafted this AJAX call
$.ajax({
url:"https://stackexchange.com/oauth/access_token",
type:"POST",
data: {
client_id: myClientID,
client_secret: myClientSecret,
code: getUrlParameter("code"),
redirect_uri: "https://myapp.com/sameAsBefore"
},
success: function(data){
console.log(data);
}
});
However, this is not accepted.
XMLHttpRequest cannot load https://stackexchange.com/oauth/access_token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://myapp.com' is therefore not allowed access.
I tried removing the contentType
and dataType
as they will default to application/x-www-form-urlencoded
and a best guess for the returning data. No change if they are there or not.
Any ideas what I am missing?