android-sdk
android-sdk copied to clipboard
Single sign-on how to
I have a running app integrated with Spotify Authentication flow via web login so I already have a token. Docs says I can use this token to user app remote sdk but I don't get how.
ConnectionParams
doesn't seem to have a way to set the token. How should I give this params my token?
I'm also wondering about this, is there any update that allows this yet? There does not seem to be support on the Android SDK for auth token usage, whereas on the iOS SDK there is.
SPTAppRemoteConnectionParams
is the iOS equivalent object to ConnectionParams
in the Android SDK. We have this example for iOS:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
SPTAppRemoteConnectionParamsImageFormat format = SPTAppRemoteConnectionParamsImageFormatAny;
SPTAppRemoteConnectionParams *params =
[[SPTAppRemoteConnectionParams alloc] initWithClientIdentifier:@"your_client_id"
redirectURI:@"your_redirect_uri"
name:@"your_app_name"
accessToken:nil
defaultImageSize:CGSizeZero
imageFormat:format];
self.appRemote = [[SPTAppRemote alloc] initWithConnectionParameters:params
logLevel:SPTAppRemoteLogLevelDebug];
self.appRemote.delegate = self;
return YES;
}
and this example on Android:
// Set the connection parameters
ConnectionParams connectionParams =
new ConnectionParams.Builder(CLIENT_ID)
.setRedirectUri(REDIRECT_URI)
.showAuthView(true)
.build();
You can see clearly that token usage is provided directly in the iOS SDK but not the Android SDK.
There is a paragraph on using a token but there are no answers at the links provided.
Download and add Authorization Library to your project as described in this guide. Create and send the authorization request as described in the Android SDK Authorization Guide. You need the app-remote-control scope to use the Spotify App Remote SDK.
Am I missing something here? It looks like it's not supported since we need to use SpotifyAppRemote.CONNECTOR.connect
in some way to get a valid SpotifyAppRemote
object with which to initiate playback, etc. Simply authenticating with app-remote-control
is not enough to actually use it.
I'm having the same issue. I successfully get a Token from the installed Spotify app, but don't know how to create an SpotifyAppRemote with it.
Hey folks - we're looking into improving the documentation / sample code for this. Stay tuned!
@arirawr Any update on this? I'm able to get a token and am unsure of how to proceed
Hi @arirawr , as far as I am able to gather, this is not a documentation issue, it is incomplete support by the SDK which will require a fix update.
Hi @arirawr, do you have any update related to this? We are trying to create a token using the authorization library that we want to use both with the Web API SDK and the SpotifyAppRemote, but we do not found the way to pass the access token to the SpotifyAppRemote.
Can you help us with this? Thanks
Has anyone found an answer to this problem? I facing the exact same issue and as far as I know, the documentation doesn't explain anything about how to get the ConnectionParams object with existing tokens... It is written that it's supposed to be possible, but I haven't figured out how... To be honest, looking trough the sdk code, I think this feature isn't even implemented, so this issue shouldn't be marked as "documention".
I too am looking for an answer to this. Would be great to not have to different sources of authorization to use both the Web API and the AppRemote.
I'm looking for this feature too. Is there any workaround for this?
Anyone?
Also shocked this feature doesn't exist; requiring users to sign in twice feels like a complete show-stopper for my integration. Spent a full hour looking over the reference and docs trying to figure out what I was missing, considering they all certainly implied you could just pass a token on into the App Remote APIs.
Meanwhile, the iOS SDK does let you simply provide whatever access token you want when connecting the app remote, making this all the more baffling: https://developer.spotify.com/documentation/ios/quick-start/#connecting-to-spotify
For an Android app I'm working on we were using the Streaming SDK. Seeing it is deprecated and the repo is being removed November 1st we wanted to migrate to this Android SDK.
Previously we requested an auth token using the flow described by Spotify that also returns a refresh token so we could silently refresh the token before it expired and the user could continue to use the app.
With this SDK I noticed that the token retrieved after login is also only valid for an hour and there is no refresh token nor is there a method to trigger a refresh. Our app stops working after an hour untill a new login is triggered.
There's also no way of setting the auth token so we could refresh it using the refresh token. The only way that seems to be possible is to trigger a login every hour. No user interaction is necessary as the user is already logged-in and the scope doesn't change but still the login is visible on screen.
The iOS SDK has a way of setting an auth token.
To me this looks like Spotify has deprecated a SDK that worked perfectly fine without providing a working alternative.
Maybe I've missed something in the documentation and examples and if I did and there is a way of getting this to work I gladly hear it.
Any news about this? You're showing the benefits of Single sign-on in the documentation and it doesn't actually work
@arirawr I really think the lable "documentation" seems to be wrong here since looking at the exposed android api, there is no way to use your own access token.
@mcluky I'm sorry but I'm no longer at Spotify and can't help you with this.
Any news on this issue? It would be really cool to be able to use the access token that we retrieve with a refresh token with the SpotifyAppRemote.
Why is that everytime I go to use a public API, I spend ages getting everything working, only to find out that something really basic and essential is not actually included.
Seriously, how has this issue been here for 2 years and it still isn't fixed?
How wrong I was that I could quickly make an application using this authentication library, I looked at the source code, re-read the documentation until I realized that we do not have an easy way to update the access token, then why do we need this library?
I am used AppAuth library and feeling good
I was frustrated when I found out we can't refresh token so I've implemented a solution using AppAuth library to make it easy to integrate into Android apps. The project is a fork from spotify-web-api-android.
Check the needed auth dependency and this section to get access token and silently refresh token in your app.
Hope I'm allowed to share here and hope this helps.
I am having the same issue while integrating Android SDK to my app. I get the access token from web API and want to set it to SpotifyAppRemote. Could anyone help this?
It has been almost 4 years now... Are there any plans to implement a way to get refresh tokens from the Spotify App?
Haha, they're probably all busy making the UX a little worse in the next app update.
Seriously though, my impression is that this SDK was brought to life by a specific team at Spotify. That team probably fell apart for some reason (it happens), and no one who's left even knows how the SDK works anymore. I wouldn't get my hopes up on this issue being resolved this year.
I wanted to get just the Authorization Code, but I'm it's returning empty. Anyone could grab It successfuly?