Spotify Android SDK身份验证错误

时间:2018-04-03 14:41:51

标签: android spotify

过去几天我一直在试用Spotify SDK for Android。我编写了一个工作得很好的简单应用程序。但是,今天Spotify身份验证开始给我一个错误。我无法确定错误,因为我找不到要查找的错误代码。请注意,我对API一般不太熟悉。

这是我onCreate()

上的代码
AuthenticationRequest.Builder builder = 
             new AuthenticationRequest.Builder(SpotifyAPI.CLIENT_ID, 
                      AuthenticationResponse.Type.TOKEN, 
                      SpotifyAPI.REDIRECT_URI);

builder.setScopes(new String[]{"user-read-private", "streaming", "user-library-read"});
AuthenticationRequest request = builder.build();

AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);

Log.d("login", "login attempted");

这是onResult()

if (requestCode == REQUEST_CODE) {
    Log.d("login", "login result");
    AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);

    switch (response.getType()) {
        // Response was successful and contains auth token
        case TOKEN:
            SpotifyApi api = new SpotifyApi();

            api.setAccessToken(response.getAccessToken());
            SpotifyAPI.getInstance().setSpotifyService(api.getService());
            Log.d("login", "logged in");
            setResult(RESULT_OK);
            finish();
            break;

        // Auth flow returned an error
        case ERROR:
            Log.d("login", "login error");
            break;

突然调用ERROR个案。值得注意的是,虽然身份验证在我的手机上返回错误,但在虚拟设备上它只是不会返回结果。有任何想法吗?非常感谢!

0 个答案:

没有答案