I am sending a POST
request to a server to fetch a token through axios with a Content-Type
header of x-www-form-urlencoded
. I tried the same with postman and it works fine. I'm sending a key value pair of grant_type and client_credentials in the request body.
This is my axios request:
axios.post(`${baseURI}/protocol/openid-connect/token`, data, {
headers : {
"Authorization" : "Basic " + token,
"Content-Type" : "application/x-www-form-urlencoded"
},
withCredentials: true
}).then(response => {
AUTH_TOKEN = response.data.access_token;
console.log(response.data);
}).catch(error => {
console.log(error.response);
})
The data object consists of the client_credentials.The same credentials gives a successful response in postman.