I'm a little bit stuck trying to understand OAuth flows. I'm currently using Spotify API, and I've used passportjs to authenticate users. The thing that I'm not understanding is how to do api calls from my app now that the user has been authenticated.
Here is the complete code of my app, but in this part, how can I access to the access_token to fetch playlists data?
app.get('/playlists', ensureAuth, async(req,res,next) => {
let playlists_url = `https://api.spotify.com/v1/users/${req.user.id}/playlists`;
res.render('playlists')
})
Because, as I was told, store the access token somewhere in this part
function(accessToken, refreshToken, expires_in, profile, done) {
process.nextTick(function(){
return done(null, profile);
})
}
isn't the best practice. But how do I recover the access token then?
Any help/comment is well recieved. Thanks!