I'm making an Android app which uses the Spotify app-remote SDK. But it gives an error when connecting to the Spotify server. The code is the same as the code of the example project of Spotify included with the SDK. I changed the client id en redirect URI values to mine but it gives the authentication error.
I'm using release 0.6.3
Thank you in advance!
package com.example.geekxy;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.spotify.android.appremote.api.ConnectionParams;
import com.spotify.android.appremote.api.Connector;
import com.spotify.android.appremote.api.SpotifyAppRemote;
public class LoginSpotify extends AppCompatActivity {
private static final String CLIENT_ID = "bxxxxxxxxxxxxxxxxxxxxxxxxd7";
private static final String REDIRECT_URI = "com.example.geekxy://callback";
private SpotifyAppRemote mSpotifyAppRemote;
private TextView testo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_spotify);
}
@Override
protected void onStart() {
super.onStart();
testo = findViewById(R.id.stato);
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) {
mSpotifyAppRemote = spotifyAppRemote;
Log.d("Main Activity", "Connected!");
Connected();
}
@Override
public void onFailure(Throwable throwable) {
Log.e("MyActivity", throwable.getMessage(), throwable);
testo.setText("NOT WORKS");
}
});
}
@Override
protected void onStop() {
super.onStop();
SpotifyAppRemote.disconnect(mSpotifyAppRemote);
}
private void Connected() {
mSpotifyAppRemote.getPlayerApi().getPlayerState();
mSpotifyAppRemote.getPlayerApi().skipNext();
testo.setText("IT WORKS");
}
}
E/MyActivity: {"message":"com.spotify.mobile.android.spotlets.appprotocol.model.AppProtocol$Message"} com.spotify.android.appremote.api.error.AuthenticationFailedException: {"message":"com.spotify.mobile.android.spotlets.appprotocol.model.AppProtocol$Message"} at com.spotify.android.appremote.api.LocalConnector.asAppRemoteException(LocalConnector.java:131) at com.spotify.android.appremote.api.LocalConnector.access$000(LocalConnector.java:35) at com.spotify.android.appremote.api.LocalConnector$1.onConnectionFailed(LocalConnector.java:111) at com.spotify.android.appremote.internal.SdkRemoteClientConnector$ConnectionTask.onPostExecute(SdkRemoteClientConnector.java:142) at com.spotify.android.appremote.internal.SdkRemoteClientConnector$ConnectionTask.onPostExecute(SdkRemoteClientConnector.java:75) at android.os.AsyncTask.finish(AsyncTask.java:695) at android.os.AsyncTask.access$600(AsyncTask.java:180) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7078) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) Caused by: com.spotify.protocol.client.error.RemoteClientException: {"message":"com.spotify.mobile.android.spotlets.appprotocol.model.AppProtocol$Message"} at com.spotify.protocol.client.RemoteWampClient.getRemoteClientException(RemoteWampClient.java:139) at com.spotify.protocol.client.RemoteWampClient.access$200(RemoteWampClient.java:16) at com.spotify.protocol.client.RemoteWampClient$1.onAbort(RemoteWampClient.java:44) 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:78) at com.spotify.android.appremote.internal.RemoteServiceIo.handleMessage(RemoteServiceIo.java:113) at com.spotify.android.appremote.internal.RemoteServiceIo.access$000(RemoteServiceIo.java:47) at com.spotify.android.appremote.internal.RemoteServiceIo$IncomingHandler.handleMessage(RemoteServiceIo.java:91) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7078) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)