react-native-spotify-remote icon indicating copy to clipboard operation
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?

Open rohit-ganapathy opened this issue 4 years ago • 7 comments

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.

rohit-ganapathy avatar Jul 19 '20 18:07 rohit-ganapathy

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.

cjam avatar Jul 24 '20 20:07 cjam

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.

rohit-ganapathy avatar Jul 25 '20 09:07 rohit-ganapathy

Gotcha. Is this android or iOS?

cjam avatar Jul 29 '20 04:07 cjam

android. I should have mentioned in the issue. sorry for that.

rohit-ganapathy avatar Aug 02 '20 10:08 rohit-ganapathy

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.

cjam avatar Aug 10 '20 17:08 cjam

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. 👍

jose31canizar avatar Nov 19 '20 12:11 jose31canizar

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.

cjam avatar Nov 19 '20 16:11 cjam