hi, i am trying to login through OAuth using API with fetch, I have make sure that Content Type is application/x-www-form-urlencoded, the response returns False with an error : {“error”:“unsupported_grant_type”} I tested it in postman and it works just fine!
Here is My Code:
fetch('http://192.168.98.219/API/Token',{ method: 'POST', headers: { "Content-type": "application/x-www-form-urlencoded" }, body:JSON.stringify({ grant_type:'password', Username:"agent1@live.com", Password:"123456" }) }) .then(function(response) { console.log("Body Text:"+response._bodyText); console.log(JSON.stringify(response)); }) .catch(function(err) { console.log("Fetch error: " + err); });
Please help !!