SOLUTION: I was using the wrong Content-Type
- I had x-www-form-urlencoded should (for this snippet) be json
I am working on a local copy of an app and am getting a 400 response code with “Unknown grant_type”.
I have done some googling and only references to this that I found were because the grant_type was actually wrong. This is not the case in my code. I have seen some other posts about this as well but for other auth paths that weren’t similar enough to get a resolution from.
Any help / suggestions are very much appreciated.
I am using Node.js with requests module installed. Code is below:
(ID:SECRET string is redacted)
request.post({
url: "https://login.eveonline.com/oauth/token",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic id:secret"
},
body: JSON.stringify({
"grant_type": "authorization_code", //line that seems to be generating the error
"code": code
}),
},
function(e, r, b) {
if (e) {
console.log("An Error");
console.log(e);
} else {
console.log(b);
}
}
);