Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotify app refuses app connection attempts after switching Spotify account #426

Open
Fump opened this issue Jun 18, 2024 · 0 comments
Open

Comments

@Fump
Copy link

Fump commented Jun 18, 2024

I've been trying to implement handling for when an authenticated user switches their Spotify account and found that there seems to be a bug in the Spotify app here. I've also been able to observe and reproduce the same issue in other AppStore apps with Spotify integration.

SDK version: 2.1.1
Spotify iOS App version: 8.9.48

The issue can be reproduced with using both SDK provided authentication methods:

  1. Receiving access token by calling SPTAppRemote authorizeAndPlayURI:completionHandler:
  2. Receiving access token by calling SPTSessionManager initiateSessionWithScope:options:campaign:

The steps to reproduce are:

  1. User is signed into Account 1 in Spotify app and connects an App through the SDK and receives AccessToken 1.
  2. App then successfully connects to SPTAppRemote using the received AcessToken 1.
  3. User goes to the Spotify app and signs out of Account 1 and then signs into Account 2.
  4. User opens App and tries to connect to the SPTAppRemote using AccessToken 1.
  5. Connection attempt fails and appRemote:didFailConnectionAttemptWithError is called. (Expected as accessToken 1 was for Account 1)
  6. User successfully re-authenticates app for Account 2 through the SDK and receives AccessToken 2.
  7. App tries to connect to running Spotify app through SPTAppRemote using AccessToken 2.
  8. Connection attempt fails and appRemote:didFailConnectionAttemptWithError is called (Unexpected)

When is this state all future connection attempts will fail even if connecting app is restarted, new access token fetched successfully (SPTAppRemote and or SPTSessionManager with new initiateSession). Only way to recover from this state I have found is to force-close to Spotify app. After this the app can successfully connect to the Spotify App through the SDK again.

Repeated error received in appRemote:didFailConnectionAttemptWithError when calling appRemote.connect() with valid accessToken this state:
AppRemote: Connecting... AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x300208c60 {Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSLocalizedRecoverySuggestion=Reconnect the transport to the Spotify app., NSLocalizedFailureReason=A stream error has occured in the transport.}

@Fump Fump changed the title Spotify app refuses app connection attempts after switching Spotify account until re-started Spotify app refuses app connection attempts after switching Spotify account Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant