Hi all,
I've been trying to get a login working using the Resource Owner Password Grant oAuth, however I can't seem to make it work.
Here's my request:
const form = {
'grant_type': 'password',
'username': 'username',
'password': 'pass',
'scope': 'profile',
'client_id': 'client_id',
}
var formBody = [];
for (var property in form) {
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(form[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");
await fetch(`https://example.com/oauth/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: formBody
})
All I get back is an error:
{
"error": "invalid_request",
"error_description": "request must be a POST request"
}
Did I format this the wrong way or am I missing something? I've been following the oAuth docs but maybe I'm missing something. Any help would be appreciated!