react-native-spotify-remote
react-native-spotify-remote copied to clipboard
Is there a way to supply Spotify Web API access token to the remote without initialising the module?
OS: Android
So my app uses elements of the Spotify Web API as well. I maintain the access token/ refresh token deal and take the user through Oauth using the React native App Auth. when I want to supply this token to the spotify remote I am not able to do It using remote.connect(access_token) unless I call auth.initalize(spotifyConfig). The problem is that auth.initalize(spotifyConfig) opens an auth window again even though the user has been through sign up once and I have the access token and refresh token. I just might be doing it wrong. Would really appreciate some help in the regard.
Hey @rohit-ganapathy, when you're getting the access token are you specifying the remote scope?
Part of the challenge with the connection is that spotify must be running and in the foreground in order to connect to it. Hence, why it kicks over to spotify.
yep I am! and it works as well. just that the loading indicator gets a bit annoying to my users. So was wondering if there is anyway to avoid that or at least prevent the loading indicator from popping up even though it's attempting a connect. Or have it behind a splash screen.
Gotcha. Is this android or iOS?
android. I should have mentioned in the issue. sorry for that.
Yea. I'm pretty sure the android API was more limited in being able to pass in a token. But I'll check it out to see if there have been any updates.
Any updates? This would be really cool to bypass the module and just connect with the access token directly, as my app is doing something similar. 👍
Sorry I've been a bit busy with work lately so I haven't been able to dig into this. I think part of the challenge (especially on iOS), is that if spotify isn't running (or if its backgrounded on iOS) then the connect will fail. But taking a quick glance at the Android remote sample here: https://github.com/spotify/android-sdk/blob/bbd987f24d52fb70d2a0ae5517c4f65d798cf56f/app-remote-sample/src/main/java/com/spotify/sdk/demo/RemotePlayerActivity.java#L335-L358
The interface for the remote connect, takes the clientId and RedirectUri and then a success callback which is passed a fully connected SpotifyRemote (and an error callback as well). So it doesn't seem like a token can just be passed into the connect. The docs for the android spotifyRemote are here: https://spotify.github.io/android-sdk/app-remote-lib/docs/ maybe have a look and see if they've added anything to allow for connection via a token.