首页 > 解决方案 > 适用于 Android 的 Spotify 远程 SDK - AuthenticationFailedException

问题描述

到目前为止,将 Spotify Remote SDK 集成到 android 应用程序中的步骤是:

1) 在 Spotify Dashboard 上创建应用程序配置文件,

2) 生成调试指纹

3) 生成的发布指纹

4) 通过运行“this.getPackageName()”确保包名称正确,该值与指纹一起放入 Spotify 仪表板。

我能够运行我的应用程序,并且在初始启动时,spotify 身份验证页面确实会出现。但是在 1 或 2 天后,进入调试阶段,函数 connect(_:) 突然失败并返回 AuthenticationFailedException 错误

if (SpotifyAppRemote.isSpotifyInstalled(this)) {

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

        SpotifyAppRemote.connect(this, connectionParams,
                new Connector.ConnectionListener() {

                    @Override
                    public void onConnected(SpotifyAppRemote spotifyAppRemote) {
                        musicPlayer = spotifyAppRemote;
                        Log.d(TAG, "Connected! Yay!");
                    }

                    public void onFailure(Throwable error) {
                        if (error instanceof SpotifyRemoteServiceException) {
                            if (error.getCause() instanceof SecurityException) {
                                logError(error, "SecurityException");
                            } else if (error.getCause() instanceof IllegalStateException) {
                                logError(error, "IllegalStateException");
                            }
                        } else if (error instanceof NotLoggedInException) {
                            logError(error, "NotLoggedInException");
                        } else if (error instanceof AuthenticationFailedException) {
                            logError(error, "AuthenticationFailedException");
                        } else if (error instanceof CouldNotFindSpotifyApp) {
                            logError(error, "CouldNotFindSpotifyApp");
                        } else if (error instanceof LoggedOutException) {
                            logError(error, "LoggedOutException");
                        } else if (error instanceof OfflineModeException) {
                            logError(error, "OfflineModeException");
                        } else if (error instanceof UserNotAuthorizedException) {
                            logError(error, "UserNotAuthorizedException");
                        } else if (error instanceof UnsupportedFeatureVersionException) {
                            logError(error, "UnsupportedFeatureVersionException");
                        } else if (error instanceof SpotifyDisconnectedException) {
                            logError(error, "SpotifyDisconnectedException");
                        } else if (error instanceof SpotifyConnectionTerminatedException) {
                            logError(error, "SpotifyConnectionTerminatedException");
                        } else {
                            logError(error, String.format("Connection failed: %s", error));
                        }
                    }
                });
    }

logError(error, "AuthenticationFailedException"); 这被执行。

在这一点上,我不确定后台发生了什么。指纹是否必须以某种方式动态更新?身份验证超时和 Spotify 本身是否需要重新登录?

标签: androidauthenticationspotifyandroid-fingerprint-api

解决方案


推荐阅读