Announcements

Help Wizard

Step 1

NEXT STEP

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

Let's introduce ourselves!

Hey there you, ย  Yeah, you!ย 😁 ย  Welcome - we're glad you joined the Spotify Community! ย  While you here, let's have a fun game and getโ€ฆ

ModeratorStaff / Moderator/ 4 years ago  in Social & Random