You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Step 2 - Create an endpoint for Spotify to redirect the user to and get the authorization code Spotify passed in.
app.get("/auth/spotify/callback",(req,res)=>{constauthCode=req.query.code;/* TODO */});
Step 3 - Make a call to Spotify to turn the authorization code into an access token.
app.get("/auth/spotify/callback",(req,res)=>{// Combine client ID and secret with a colon, then base64 encode them.constauthHeader=Buffer.from(`${spotifyClientId}:${spotifyClientSecret}`).toString("base64");// Make call to get access token.constresponse=awaitaxios({url: "https://accounts.spotify.com/api/token",method: "POST",headers: {Authorization: `Basic ${authHeader}`},params: {grant_type: "authorization_code",code: authCode,redirect_uri: redirectUri}});/* Store access token somewhere */console.log(response.data.access_token);:
});