spotify / android-sdk

Spotify SDK for Android
https://developer.spotify.com/documentation/android/
Apache License 2.0
473 stars 120 forks source link

AUTHENTICATION_SERVICE_UNAVAILABLE Explicit user authorization is required to use Spotify. The user has to complete the auth-flow to allow the app to use Spotify on their behalf com.spotify.error.user_not_authorized #349

Closed rhiskey closed 1 year ago

rhiskey commented 1 year ago

Same: This error is back. I am also getting AUTHENTICATION_SERVICE_UNAVAILABLE when I have spotify installed. Tested for API 29 and 31.

Originally posted by @EmreSafaCelik in https://github.com/spotify/android-sdk/issues/307#issuecomment-1356864869

@veronikapetruskova

Hi @rhiskey @EmreSafaCelik @sean-pearson ! Can you check if you're having issues with the latest version 2.1.0 as well? https://github.com/spotify/android-auth

Yes, issues with (com.spotify.android:auth:2.1.0) too, im using it with spotify-app-remote-release-0.8.0.aar I also tried various auth methods, e.x:

        val builder = AuthorizationRequest.Builder(
            CLIENT_ID,
            AuthorizationResponse.Type.TOKEN,
            REDIRECT_URI
        )

        builder.setScopes(arrayOf("streaming", "user-read-private", "playlist-read", "playlist-read-private"))
        val request = builder.build()

        AuthorizationClient.openLoginActivity(this, SPOTIFY_REQUEST_CODE, request)

This one above opens pop-up window with "loading" and immediately closes. There used to be an application authorization menu, now the pop-up menu just closes and that's it. Assuming that REDIRECT_URI and CLIENT_ID set in developers dashbord (and in code + AndroidManifest too ) so it works well and finally causes intent <- there's no issue (tested).

And browser-based:

        val builder = AuthorizationRequest.Builder(
            CLIENT_ID,
            AuthorizationResponse.Type.TOKEN,
            REDIRECT_URI
        )

        builder.setScopes(arrayOf("streaming", "user-read-private", "playlist-read", "playlist-read-private"))
        val request = builder.build()

       AuthorizationClient.openLoginInBrowser(this, request);

This one above not works at all (i used to write custom intents like in Spotify SDK docs, but no one worked yet).

I cant auth in Spotify via spotify-app-remote approximately since January 2023. Last working method before Jan 2023 was calling connect method passing connectionParams and it automatically opens auth menu:

        val connectionParams = ConnectionParams.Builder(CLIENT_ID)
            .setRedirectUri(REDIRECT_URI)
            .showAuthView(true)
            .build()

        SpotifyAppRemote.connect(context, connectionParams,
 object : ConnectionListener {
                override fun onConnected(spotifyAppRemote: SpotifyAppRemote) {
                    mSpotifyAppRemote = spotifyAppRemote
                    listenAppRemoteLiveData.postValue(spotifyAppRemote)
                    // Now you can start interacting with App Remote
                    connected()

                }

                override fun onFailure(throwable: Throwable) {
                    onDisconnected()

                    // Something went wrong when attempting to connect! Handle errors here
                }
            })

But since January it causes AUTHENTICATION_SERVICE_UNAVAILABLE error.

Tested on Android API 30, API 33

Hope it will help fixing issue. Please let me know if more bug details are needed.

@rhiskey can you check if you're using correct debug and release package SHA1 fingerprints for your app package names in the developer dashboard?

@veronikapetruskova Sure, double-checked and added SHA1 fingerprints once again, so here's request:

Spotify Auth starting with the request [https://accounts.spotify.com/authorize?client_id=XXXXXX&response_type=token&redirect_uri=http%3A%2F%2Fcom.PUBLISHER.NAME%2Fcallback&show_dialog=false&utm_source=spotify-sdk&utm_medium=android-sdk&utm_campaign=android-sdk&scope=streaming%20user-read-private%20playlist-read%20playlist-read-private]

and responce: image

image

rhiskey commented 1 year ago

@rhiskey can you check if you're using correct debug and release package SHA1 fingerprints for your app package names in the developer dashboard?

@veronikapetruskova Sure, double-checked and added SHA1 fingerprints once again, so here's request:

Spotify Auth starting with the request [https://accounts.spotify.com/authorize?client_id=XXXXXX&response_type=token&redirect_uri=http%3A%2F%2Fcom.PUBLISHER.NAME%2Fcallback&show_dialog=false&utm_source=spotify-sdk&utm_medium=android-sdk&utm_campaign=android-sdk&scope=streaming%20user-read-private%20playlist-read%20playlist-read-private]

and responce: image

image

rhiskey commented 1 year ago
 Message from Spotify: [3,{"message":"Explicit user authorization is required to use Spotify. The user has to complete the auth-flow to allow the app to use Spotify on their behalf"},"com.spotify.error.user_not_authorized"]
2023-08-18 23:39:59.552  6689-6689  SPOTIFY_APP_REMOTE      com.XXX.XXXX D  Connection failed.
                                                                                                    com.spotify.protocol.client.error.RemoteClientException: {"message":"Explicit user authorization is required to use Spotify. The user has to complete the auth-flow to allow the app to use Spotify on their behalf"}
                                                                                                        at com.spotify.protocol.client.RemoteWampClient.getRemoteClientException(RemoteWampClient.java:130)
                                                                                                        at com.spotify.protocol.client.RemoteWampClient.access$200(RemoteWampClient.java:16)
                                                                                                        at com.spotify.protocol.client.RemoteWampClient$1.onAbort(RemoteWampClient.java:43)
                                                                                                        at com.spotify.protocol.client.WampRouterImpl.routeAbort(WampRouterImpl.java:100)
                                                                                                        at com.spotify.protocol.client.WampRouterImpl.route(WampRouterImpl.java:26)
                                                                                                        at com.spotify.protocol.client.AppProtocolCommunicator.onData(AppProtocolCommunicator.java:77)
                                                                                                        at com.spotify.android.appremote.internal.RemoteServiceIo.handleMessage(RemoteServiceIo.java:108)
                                                                                                        at com.spotify.android.appremote.internal.RemoteServiceIo.access$000(RemoteServiceIo.java:45)
                                                                                                        at com.spotify.android.appremote.internal.RemoteServiceIo$IncomingHandler.handleMessage(RemoteServiceIo.java:86)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                        at android.os.Looper.loop(Looper.java:288)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
rhiskey commented 1 year ago

UP

LidiiaPl commented 7 months ago

Is the solution found? I'm facing the same issue.

haashem commented 5 months ago

me too.