cjam / react-native-spotify-remote

React Native wrapper around the Spotify Remote SDK
MIT License
258 stars 101 forks source link

QUESTION: After session/token from Spotify expires, does requesting a new session/token always opens and switches to the Spotify App? #229

Open bumpingChris opened 1 year ago

bumpingChris commented 1 year ago

I would like to be able to request a new session/token from Spotify without switching to the Spotify app. This might be related to: https://github.com/cjam/react-native-spotify-remote/issues/42#issuecomment-820449988

Here are what I'm confused about:

  1. Is there a way to prevent having to always open the Spotify App? Is that what the refresh-token is for?
  2. If refresh-token / renew session is the way, it seems we have to implement/call the refresh token mechanism ourselves atm - it is not part of the example.
  3. How long a life does the refresh-token have before it expires as well?
cjam commented 1 year ago

Hey good question. I haven't had a chance to get the refresh tokens figured out. Ideally this library could transparently refresh them and maintain the connection. I have found the iOS implementation from spotify to be challenging due to iOS backgrounding spotify after inactivity. So then the only way to wake it up is through the auth flow. That being said, if it's still awake in the background, I'm sure you could try and use the web sdk to refresh the token and then try to use this library to re-establish the connection with the new token.

Again, I haven't tried it, but that's the approach I would try first. The tokens should come back with expiry dates, but I don't recall if I was exposing all of that through this library.

bumpingChris commented 1 year ago

Hey good question. I haven't had a chance to get the refresh tokens figured out. Ideally this library could transparently refresh them and maintain the connection. I have found the iOS implementation from spotify to be challenging due to iOS backgrounding spotify after inactivity. So then the only way to wake it up is through the auth flow. That being said, if it's still awake in the background, I'm sure you could try and use the web sdk to refresh the token and then try to use this library to re-establish the connection with the new token.

Again, I haven't tried it, but that's the approach I would try first. The tokens should come back with expiry dates, but I don't recall if I was exposing all of that through this library.

@cjam Thank you for your response and your effort on this. Really appreciate it. I'll play around with trying to get the refresh to work.