I am trying to make a POST request but am getting the following message in my chrome network tab:
{error: "unsupported_grant_type",…} error: "unsupported_grant_type" error_description: "grant_type must be client_credentials, authorization_code or refresh_token"
I have been using Axios for RESTful calls and this is the POST request:
async componentDidMount() {
const encodedString = 'blah'//some encoded string
const [initSpotResponse] = await Promise.all([
axios.post('https://accounts.spotify.com/api/token',
{ data: { grant_type: 'client_credentials' } },
{
headers: {
'Authorization': `Basic ${encodedString}`,
'Content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
}
}
)
]);
}
I've tried all sorts of things mentioned in other StackOverflow posts but nothing has seemed to work. Does anyone have any experience creating such a POST request? I haven't seen an axios-specific post about this issue - should I abandon axios (what should I switch to if so)?