spotify/android-sdk

Auth-Flow: AUTHENTICATION_SERVICE_UNAVAILABLE

maxkeppeler opened this issue · 33 comments

Issue found on DATE. ~ 07.12.2021

SDK Version:

spotify-app-remote-release-0.7.2 & spotify-app-remote-release-0.7.0
spotify-auth:1.2.5 & spotify-auth:1.2.6, .. And any I tried

OS Version: Android version 10 (Huawei P30 Pro & Samsung Galaxy s20)

Scope(s):

Steps to reproduce:

  1. Starting auth-flow
  2. calling AuthorizationClient.openLoginActivity()
  3. LoginActivity is immediately closed after being shown (all black window)

Expected behaviour: Normal auth-flow process

Actual behaviour: Auth-flow fails

AuthorizationResponse always returns error: AUTHENTICATION_SERVICE_UNAVAILABLE
Bildschirmfoto 2021-12-26 um 15 13 08

Any updates to this? I'm facing the same issue.

This is happening for me too. Please any update??

Facing same issue. Spotify not cooperating at all.

i noticed i had this issue when trying to use the auth & app-remote libraries together.

i removed the app-remote lib and everything was fine. this is a problem however as i need to use it in my app, trying to find a solution :(

Hi, I'm looking into this for Spotify.

Looking at the screenshots above, it seems like the first screenshot is from auth-lib and the second one is from app-remote.

This error message is expected to happen in app-remote if you try to connect to app-remote with a non-authenticated user without setting the connection parameter "showAuthView" to true, i.e. you need to do something like:

SpotifyAppRemote.connect(
        context,
        new ConnectionParams.Builder(CLIENT_ID)
            .setRedirectUri(REDIRECT_URI)
            .showAuthView(showAuthView) // <-- !!
            .build(),
        connectionListener)

This error-message is not, however, expected to happen for auth-lib. I've been trying to reproduce this with no luck. Could you give any additional information to help us reproduce this issue?

  • Which Spotify version are you using?
  • Does this issue occur on the latest Spotify version (currently 8.6.68)
  • Are you trying to connect using auth-lib and app-remote at the same time?
  • Is the user logged in or logged out?
  • Could you provide us with a code-snippet showing how you connect to the auth-lib? (not including any sensitive information related to your app, of course)
  • Any other information?

Hi @pimpimmi

My code snippet is simple (kotlin):

    val connectionParams = ConnectionParams.Builder(ClientID)
        .setRedirectUri(RedirectURI)
        .showAuthView(true)
        .build()


    runOnMain {
        SpotifyAppRemote.connect(main, connectionParams, object : Connector.ConnectionListener {
            override fun onConnected(remote: SpotifyAppRemote) {
               // NEVER GET HERE
            }

            override fun onFailure(error: Throwable) {

                if (error is CouldNotFindSpotifyApp) {
                    // TODO: Tell user that they need to install the spotify app on the phone
                }

                if (error is NotLoggedInException) {
                    // TODO: Tell user that they need to login in the spotify app
                }

                if (error is UserNotAuthorizedException) {
                    // Getting this:
                    // 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
                    // And AUTHENTICATION_SERVICE_UNAVAILABLE in logcat, as screenshots.
                }
            }
        })
    }

By now I've tried the auth library also, and it similarly freaks out when going through the app, and gets me a token just fine with going through the web auth route. As someone above the app shows up for just a second, spins a wheel, and returns control to my app.

I've also made a brand new app, new client/secret pair, tested with a new spotify account, old (2009 smeth) account, and a recent-ish account from a friend. A healthy mix of premiums and so on. Tested playing some music, works fine.

I got the latest spotify app from Google Play, which self-identified as 8.6.98.900. Tested on two recent Android phones, with same exact result.

If you'd like we can have a chat on the phone, and I can demo the problem.

@voxmate-gleb What do you mean it "freaks out" when using auth-lib? If the user is authorized, expected behaviour is for a popup to be quickly shown before returning the token.

Regarding app-remote. Does the app-remote sample app work for you? Have you entered client-id or redirect uri exactly as in https://developer.spotify.com/dashboard and does the package name + signature match? Do you get any error logs from Spotify (adb logcat -s Spotify)?

@pimpimmi

I mitigated the issue by getting rid of auth-lib and moving that to a react native webview based auth system.

but for app-remote running into an issue where i'm now receiving the "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" error even after following/copying the example code exactly.

In fact the auth window/dialog doesn't even appear, and i have .showAuthView(true) in my ConnectionParams constructor.

@jadenbanson Could you verify that the redirecturi, client id, package name and signature are the same as you have set on https://developer.spotify.com/dashboard?

Do you get any log messages from Spotify when using "adb logcat -s Spotify" ?

Screenshot 2022-01-26 at 09 11 21

@pimpimmi Hi I verified that redirecturi, client id, package name and signature are matching on the app and in the dashboard.

I am getting no log messages from Spotify when using "adb logcat -s Spotify"

still getting this error:

com.spotify.android.appremote.api.error.UserNotAuthorizedException: {"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"}

hey @pimpimmi any update on this? sorry for being pushy, this issue has just been blocking progress.

@jadenbanson We have been unable to reproduce this issue and seeing nothing to indicate there is a bug on our end.

I would suggest you double-check your setup to make sure everything is correct. If you still believe there is an issue with the SDK, we would need to get more detailed instructions how to reproduce the issue from our end.

An app that had been using the Spotify auth randomly stopped working here too without me changing anything. All I'm getting is the Authentification_Serivce_Unavailable. Can't seem to figure out a way to get it to work now.

@jadenbanson @AndroidJulian Do you have any APK you could share? That way we could check if there is a bug in the Spotify app.

@pimpimmi do you have an email i could send the APK to?

Also our app is RN + Native android, would this have something to do with the dialog not being presented/auth not working?

@jadenbanson I'll send you an email from my Spotify mail.

We haven't verified the SDK's work as they should when using RN, so I wouldn't rule it out.

Responded to your email with the SDK :)

@jadenbanson Looks like the signature in that APK doesn't match with the one you have registered on https://developer.spotify.com/dashboard. I'll email you more details.

@pimpimmi I think the APK signature may have changed when I compiled the APK, i just added the new signature to the dashboard, but still getting the same results when I test the APK

@pimpimmi We are still seeing the issue. Any updates?

Having the same issue, the authorization login loads then immediately disappears, it used to work fine before.

I have the same issue, Any updates?

We are still investigating the issue and are still not able to reproduce.

We suspect it might have something to do with the internal cache in the app. Could you try clearing the app data and check if it works?

It would also be helpful if you could send us the client-id for your app. You can send it to joachimn@spotify.com if you don't want to post it here.

@pimpimmi - Would you like a screencast demo of the problem? I have 100% reproducibility on two test devices. Just ping me at @voxmateapp on twitter.

gghzc commented

I have the same issue, Any updates?
AuthorizationResponse always returns error: AUTHENTICATION_SERVICE_UNAVAILABLE
And the other problem is, i have setShowDialog(false) but it still display the ”loading...“ view
(spotify-app-remote-release-0.7.2 & spotify-auth-release-1.2.3.aar)

Also got this error. Tried on both auth standalone and remote sdk.

  1. No Spotify app installed on device
  2. Open target app, launch/click Spotify login
  3. In the launched WebView, add credentials. Allow access to the app scopes
  4. ✅ Access Token is returned
  5. Open play store and install/open Spotify app. Perform login
  6. Fresh install/wipe data the target app
  7. Open the target app, launch/click Spotify login
  8. A Dialog is shown with a loading, but very quickly (1 sec) disappears.
  9. ❌ Error AUTHENTICATION_SERVICE_UNAVAILABLE, no access token
  10. Unistall Spotify app
  11. Open target app, launch/click Spotify login
  12. Perform login using WebView
  13. ✅ Access Token is returned

More info

  • ONEPLUS A6003
  • Android 11
  • Spotify BETA app version
  • Remote sdk 0.7.2, auth version 1.2.6
  • Spotify api on "sandbox/development" mode
  • Tried every instructions on this issue

Very happy to share that I fixed the issue from my side 🥳

The problem was missing SHA1 configuration on Spotify developer portal.

✅ Auth and Remote libs working as expected now.

gleno commented

For people who are still struggling - I have the solution!

A SHA-1 fingerprint is just bytes, to print it we use various notations - spotify wants something like E1:AA:EE.... etc. The notation has to be upper case, and not e1:aa:ee... the notations are completely equivalent, but spotify only accepts the upper case version, and will give a cryptic AUTHENTICATION_SERVICE_UNAVAILABLE if you plop down the lowercase SHA.

It took me very long to find the issue in my case. Maybe it helps others, too.
Maybe first thing to mention, apk needs to be signed and since I didn't find it in the QuickStart guide, here you can find the necessary gradle config:
https://github.com/spotify/android-auth/blob/master/auth-sample/build.gradle#L28

Also worth mentioning, in addition to the releases of the auth libraray here in this repo under releases, there is a more recent version published that I'm using now (not sure if it makes a difference...)

implementation 'com.spotify.android:auth:2.0.0'

And now the tricky part:
I probably made a mistake with the signing in the beginning and that led to situations with very strange behavior - sometimes it worked, sometimes not. I had the feeling my app hits the auth API with a different certificate - and actually yes, this was the case. So, if you are changing something with the singing of the apk and you're using Android Studio for debugging, a change in the certificate should show you this message:
Screenshot from 2022-12-10 21-17-26

If not, this is a good hint that something is wrong - as I had to learn ;-)
A good help is also:

apksigner verify -print-certs ./app/build/intermediates/apk/debug/app-debug.apk

If this shows different signing information (compared to before your changes...) and the popup message does NOT show up, you probably ran into the same problem as I did.

Long story short, check the debug configs and tick the 2 settings (Run -> Edit configurations):
Screenshot from 2022-12-10 21-14-59
It disables deployment optimizations and clears the app storage.
(I think the 'deployment optimizations' is the relevant part, not the storage clearing)

@pimpimmi did you have any luck tracking down the issue with the spotify-remote-app SDK? I seem to be getting the same issue as @jadenbanson

2022-12-14 12:54:09.263 28175-28175/com.learnanimations E/MyActivity: {"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.android.appremote.api.error.UserNotAuthorizedException: {"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"}

For people who are still struggling - I have the solution!

A SHA-1 fingerprint is just bytes, to print it we use various notations - spotify wants something like E1:AA:EE.... etc. The notation has to be upper case, and not e1:aa:ee... the notations are completely equivalent, but spotify only accepts the upper case version, and will give a cryptic AUTHENTICATION_SERVICE_UNAVAILABLE if you plop down the lowercase SHA.

This fixed my issue.

@pimpimmi did you have any luck tracking down the issue with the spotify-remote-app SDK? I seem to be getting the same issue as @jadenbanson

2022-12-14 12:54:09.263 28175-28175/com.learnanimations E/MyActivity: {"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.android.appremote.api.error.UserNotAuthorizedException: {"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"}

Same issue