spotify / web-api-examples

Basic examples to authenticate and fetch data using the Spotify Web API
Apache License 2.0
1.98k stars 1.66k forks source link

Question about Authorization flow #54

Open Jay-zsy opened 4 years ago

Jay-zsy commented 4 years ago

Hi guys, I have deployed my node/express server on Heroku and my create-react-app on netlify. The end goal I am trying to achieve here is to have a seemless transition between each access token expiring. Right now when I am listening on my app, after 1 hour the access token expires and I have to manually refresh the page to login again. As per the documentation, it is possible to extend a session by hitting the /refresh route if you already have a refresh token and your secret credentials. The part I am not understanding is the granular details of the response.redirects

https://github.com/hollowic/music-player-backend/blob/42ce542f6bc6c1ba00f429370071b08dbea46ba9/server.js#L104

When I send an AJAX request, it seems to be blocked here and I am not experienced enough with node/express nor oauth to understand what this redirect really entails. I tried to rewrite it using an axios.get request but that didn't seem to get me anywhere

I was wondering if it was possible to have the heroku app send the new access token to the front end, before each old access token expired since I seem to get CORS errors when I try to do an AJAX request from netlify. And how would that look like?

Thank you so much for taking the time to read my question.