Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Error 415: unsupported media type Spotify API [ReactJS]
Author Summary
OpenForPeople is in ReactJS
Post Body

Hi everybody, I'm trying to get the access token from the spotify API but I keep getting the error in the title.

I suppose it has something to do with the type of request and using axios which does not support it but I'm kind of lost on how to solve this or what is actually going wrong.

Expected outcome: Status 200 with access and refresh token.

outcome right now: Error 415

The request is the following:

async function getAccesToken(authorizationCode){
const client_id_base64 = Buffer.from(client_id).toString('base64')
const client_secret_base64 = Buffer.from(client_secret).toString('base64')

try{
const requestToken = await axios.post('https://accounts.spotify.com/api/token',{
params: {
grant_type: "authorization_code",
code: authorizationCode,
redirect_uri: "http://localhost:3000/new-setlist"
},
headers: {
"Authorization": 'Basic ${client_id_base64}:${client_secret_base64}',
"Content-Type": "application/x-www-form-urlencoded"
}})
console.log(requestToken)
} catch(e){
console.error(e)
}
}

Any help would be appreciated

Author
Account Strength
100%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
20,361
Link Karma
45
Comment Karma
20,233
Profile updated: 4 days ago
Posts updated: 1 year ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago