Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

refresh token always invalid

refresh token always invalid

so, i have a personal project where i want to achieve my currently playing tracks from spotify to my website. i run it in localhost:3000/ and i set the redirect uri to localhost:3000/callback. so when i authorized my account and got the refresh token, i put it into my code, but when i ran the code it keeps telling me error 400. where the response says 'invalid grant type' and the description says 'invalid refresh token'. but i'm pretty sure the refresh token is right and newly generated. so here's the code

 

 

            const token = Buffer.from(`${client_id}:${client_secret}`).toString('base64');
            const accessToken = await axios({
                method: 'post',
                url: 'https://accounts.spotify.com/api/token',
                data: `grant_type=refresh_token&refresh_token=${refresh_token}`,
                headers: {
                    Authorization: `Basic ${token}`,
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            });

 

 

but other than refresh token, i suspect the error came from the url. everytime i opened https://accounts.spotify.com/api/token it always showing picture below.
raaaizaa_0-1690877193477.png

 

so now i'm confused where i did wrong

Reply
0 Replies

Suggested posts