spotify / ios-sdk

Spotify SDK for iOS
https://developer.spotify.com/documentation/ios/
659 stars 187 forks source link

Used to be able to auth with player, now no longer can. #414

Open markd2 opened 7 months ago

markd2 commented 7 months ago

My app has been working well until today. I do authorizeAndPlayURI, the Spotify app comes forward, shows an "X", returns to my app, but did not authorize. I get these two errors. The Spotify app is installed, and it does play music. There are no complaints in the developer console. There is no email communication from the developer program saying we've been delisted. Happens with the Spotify app prior to the March 4 update, as well as that version.

AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x2829a6bb0 {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.}

2024-03-20-14:20:33.54-AppDelegate.swift:58 - 2055 - spotify didFailConnectionAttemptWithError Optional(Error Domain=com.spotify.app-remote Code=-1000 "Connection attempt failed." UserInfo={NSLocalizedDescription=Connection attempt failed., NSUnderlyingError=0x2829a6a00 {Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x2829a6bb0 {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.}}, NSLocalizedRecoverySuggestion=Ensure the Spotify app is installed, and try to reconnect., NSLocalizedFailureReason=Could not connect to the Spotify app.})

Thanks! ++md

zallanx commented 7 months ago

Upon looking through the issue list from the Spotify forum, it appears that the URI redirect was suddenly no longer accepted today: https://community.spotify.com/t5/Spotify-for-Developers/User-Authorization-failing-in-production/m-p/5956550

According to this issue (posted 37 minutes ago as of writing), the word spotify must be added, so it appears as "yourappname://spotify"

I am honestly quite hazy on this whole redirect URI thing, but perhaps it could be helpful to you to figuring out a solution.

To be sure, I would imagine that when your app redirects to open the Spotify app, you see briefly a "X" flash before redirecting back to your app?

markd2 commented 7 months ago

awesome! I'll go take a look and see if that fixes it for me. (and I wonder if this new restriction was communicated somewhere...)

zallanx commented 7 months ago

Nowhere as far as I am aware of. These things tend to just happen suddenly and everyone is left scrambling.

zallanx commented 7 months ago

Can confirm, I just updated my prod apps, and by adding spotify to my redirect URI so that it goes from myappname:// to myappname://spotify solves the issue.

I am also refreshing the tokens via a backend, and note that if you are using config variables, you must also update it to myappname://spotify as well

Hope this helps.

litvakle commented 7 months ago

Adding spotify helped me. How did you know that it should help?

zallanx commented 7 months ago

@litvakle There was a post about this issue on the Spotify forums (https://community.spotify.com/t5/Spotify-for-Developers/User-Authorization-failing-in-production/m-p/5956550) and the person noted in passing about a redirect URI featuring spotify appended at the end of their original URI

Edit: specifically, the person noted

We've already added a new RedirectURI mixonset://spotify although it seems not to have taken effect yet.

That was my hint to append spotify at the end of the original URI.

romoore commented 6 months ago

I'd love to recommend adding Spotify to our clients, but breaking changes like this make the company feel more like a fly-by-night startup than an established enterprise. :( Hopefully they'll learn from this and announce/migrate changes like this in the future.