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.
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
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...