Skip to content

Spotify Web Player Authentication Token Exchange Request Errors #94

Description

@thlucas1

UPDATED description / suggestions ...

Spotify development has added a TOTP (Time-based One Time Password) requirement to the service endpoint used to request the Spotify Web Player authorization token. The sp_dc and sp_key values are still being generated, but enhancements must be made to send a TOTP value with the request to get the authorization token.

This manifests itself when you configure the Spotify Web Player Cookie Credentials options in the SpotifyPlus configuration options. Attempts to issue commands to the player, as well as re-activate Chromecast devices, will result in a Token exchange request failed: 400 - Bad Request error.

What do I do now?

You should remove the Spotify Web Player Cookie Credentials SP_DC / SP_KEY values from your SpotifyPlus configuration options. If you are still using the Token Cache File for these, you need to remove the SpotifyWebPlayerCookieCredentials/Shared/<YOUR_LOGINID> settings as well.

Then it's a waiting game for me to find a fix / work-around / enhancement.

How does this affect me?

A number of things will no longer function as expected in the SpotifyPlus integration. These include:

  1. Player-related services run under the Spotify Web API access token, which give them less access than what they have when using them from the Spotify Web Player via a browser. Chromecast devices that have dropped off the Spotify Player active device list cannot be accessed nor added back into the device list; Sonos devices will transfer playback control to the Sonos Local Queue, and player functions are controlled via the Sonos Controller API - this happens outside of Spotify Connect control, which causes incorrect information to be displayed on what's really playing on the Sonos device (it's Local Queue) versus what Spotify Connect reports its playing.

  2. Previously deprecated functions for accessing Spotify algorithmic content are disabled, and will raise a deprecated exception if called: GetArtistRelatedArtists, GetTrackRecommendations, GetTracksAudioFeatures, GetFeaturedPlaylists, GetCategoryPlaylists, GetGenres.

  3. Previously deprecated functions for retrieving Spotify music catalog information will not return Spotify algorithmic data: GetPlaylist, GetPlaylistItems, and GetPlaylistFavorites. This means that items cannot be retrieved for Spotify algorithmic playlists (e.g. "Made For You" content, "Daily Mix n", "Discover Weekly", etc); The GetPlaylist function will return a 404 - Resource not found error if accessing a Spotify algorithmic playlist.

  4. For Spotify Free accounts, basic player controls are completely disabled (pause, resume, next track, volume up / down / mute). You have to use the Spotify Apps (desktop / mobile / web) to control the player.

Final thoughts / rants

It's a shame that Spotify does not support these functions via their own Spotify Web API as they do via their Web / Desktop Player applications. Not to mention a number of other things that are not even available in their API: play queue clear / reorder support; artist information details; the list goes on. Why even provide an API (which stands for Application Programming Interface) when it disables critical functionality? It seems that the Spotify Development team just keeps pulling the rug out from under developers that just want to define their own UI's to play Spotify content.

What's really frustrating is that I have spent weeks on making this functionality work with Home Assistant, and being a champion of their product / brand. At last account, I have about 1400 users depending on me for this integration, which is insignificant I am sure in their eyes.

I am just frustrated beyond measure right now, and am ready to throw in the towel!

Metadata

Metadata

Assignees

Labels

dependency issueForces outside my control are interfering with functionality

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions