librespot-org / librespot-java

The most up-to-date open source Spotify client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create session with spotify token failed

basicemotions opened this issue · comments

Describe the bug
I try to create player session using AuthenticationType.AUTHENTICATION_SPOTIFY_TOKEN, but it throw exception
xyz.gianlu.librespot.mercury.MercuryClient$MercuryException: status: 403
When i use username and password for session it works fine.

To Reproduce

Session.Builder sessionBuilder = new Session.Builder(conf);
sessionBuilder
                .credentials(
                        Authentication.LoginCredentials.newBuilder()
                                .setTyp(Authentication.AuthenticationType.AUTHENTICATION_SPOTIFY_TOKEN)
                                .setUsername(profilePrefs.getProfile().getId())
                                .setAuthData(ByteString.copyFrom(tokenPrefs.getToken(), StandardCharsets.UTF_8))
                                .build()
                )
                .setPreferredLocale(Locale.getDefault().getLanguage())
                .setDeviceType(Connect.DeviceType.SMARTPHONE)
                .setDeviceId(deviceId)
                .setDeviceName(deviceName);
playerSession = new WeakReference<>(sessionBuilder.create());

Expected behavior
player session created succesfull

Screenshots/Stracktraces/Logs
Screenshot 2023-10-25 at 17 19 55

Version/Commit
v1.6.3