I am trying to hit and endpoint which returns access token
in reactjs using fetch
. I am getting the error as:
{ "error": "invalid_request", "error_description": "Missing form parameter: grant_type" }.
Here is my snippet:
const response = await fetch(url,{
method : 'POST',
headers: {
//'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
body : JSON.stringify(
{
'grant_type' : 'client_credentials',
'client_id' : 'my_client_id',
'client_secret' : 'my_client_secret',
'scope' : 'openid'
}
)
})
Please suggest where I am doing wrong as in POSTMAN
it is working fine with same params as above.