@fload
Can you send a screen capture of your Spotify Developer App settings (hide the client I’d and secret values).
Do you have any other processes that are using that Spotify Developer App client I’d?
Also, did you download the latest AuthTokenGenerator.py source? And did you update the spotifywebapipython library to the latest version prior to running the script?
I don’t have any other processes for the Spotify developer app. I only set it up recently and used it for the standard Spotify Home Assistant integration, but I had deleted the standard Spotify integration before installing SpotifyPlus.
I installed SpotifyPlus + the associated scripts/libraries today - so it should be the latest ones.
@fload
Ya, not sure what’s going on there. I created a new issue on the Spotify Developer Discussion forum about it - hopefully they will respond with some details, but I don’t expect much from that avenue to be honest.
It sounds like they are making changes to their Developer App process, which probably does not bode well for Home Assistant users based on past experience when they make changes. They have been known to deprecate functionality without prior notice.
Hopefully it’s just temporary, but time will tell.
Based on your screen capture, it seems your Developer App settings are correct. The “API rate limit exceeded” indicates something is making too many requests to the Spotify API using your client id / secret. I have never heard of anyone experiencing this error using the integration or the AuthTokenGenerator process. This leads me to believe it’s either a temporary condition with the Spotify authorization servers, as your Spotify Developer App settings look good.
Another option at this point would be to logout of Spotify on the same computer that you are trying to run the AuthTokenGenerator process on, as well as clear your browser cache. It may be that it’s trying to use cached credentials, which might be causing the problem.
I wish I had a better answer, but at this point it’s probably a “wait and see” approach to see if it clears itself up on its own due to Spotify making changes at the server level.
Hi @thlucas, I have the same problem (429 API rate limit exceeded, when calling SetAuthTokenAuthorizationCodePKCE) so I guess there is a temporary problem, this is bad luck
(and I also made a test by logging out on my browser, then I blocked automatic tab openning, I ran your script - latest version on branch master, copy and pasted the link in incognito window, but I had the same result)
I now use Spotify Plus instead of spotcast. With spotcast, i was using a service called “spotcast.play_category” to start playback a random playlist from a Browse Category as context (For example : “Rock”). Is there such a feature with spotify plus ?
@jeyjey43 Spotify disabled that functionality in their Spotify Web API on 11/27/2024 so it is no longer available. SpotifyPlus used to support the functionality, but it no longer works due to the Spotify Web API changes. Note that SpotCast will not support it either, as it also uses the Spotify Web API to call that endpoint (I believe).
Unfortunately, there is no workaround for categories.
You could still create genre-specific playlists yourself and play them if you want though. You could then use the SpotifyPlus Player Media Play Context service to start the playlist (with shuffle enabled as well), like so:
Oddly enough, one can still retrieve the category names (and id / cover art) via the Spotify Web API; you just can’t play them, nor retrieve the list of items. Check out the SpotifyPlus Get Browse Categories for more info; example:
@tmarly
Also posted this here (same as email reply) for convenience to other users.
Hi Tristan,
The “API rate limit exceeded” indicates something is making too many requests to the Spotify API using your client id / secret. I have never heard of anyone experiencing this error using the integration or the AuthTokenGenerator process (outside of the 4 or 5 people that have posted on the forum just this week with the same error). This leads me to believe it’s a temporary condition with the Spotify authorization servers. How “temporary” is yet to be seen.
It appears Spotify is making changes to their Developer App process, due to the disabling of the “Create App” button on the Spotify Developer App page. As of a few days ago, one can no longer create a new Spotify Developer Application. This does not bode well for Home Assistant users based on past experience when they make changes. They have been known to deprecate functionality without prior notice. Hopefully it’s just temporary, but time will tell.
Another option at this point would be to logout of Spotify on the same computer that you are trying to run the AuthTokenGenerator process on, as well as clear your browser cache. It may be that it’s trying to use cached credentials, which might be causing the problem.
You will also want to update the spotifywebapipython package by issuing the following commands from a DOS terminal window (more info here) before you run the AuthTokenGenerator script:
I wish I had a better answer, but at this point it’s probably a “wait and see” approach to see if it clears itself up on its own due to Spotify making changes at the server level.
i’m reacting to one of your feedback: “The API rate limit exceeded indicates something is making too many requests to the Spotify API using your client id / secret.”
However, the script AuthTokenGenerator.py uses not mine but your client id:
@tmarly
Using your client id will not work for that token. The SPOTIFY_DESKTOP_APP_CLIENT_ID is hardcoded in the API layer that loads the token (e.g. it specifically looks for a token key with that id).
It makes me wonder if Spotify changed something on the backend to limit their client-id for use with internal only processes. If that’s the case, then it will be a huge problem since that client id is used to activate the Sonos and Google Cast devices!
However, after many tries, it’s finally working (SpotifyPlus + Sonos) without using AuthTokenGenerator.
I think that what solved the problem was to add “Spotify” in the list of services in the Sonos App (on the mobile device). But i’m not sure at all (in fact I’m using spotify + sonos since many years, without having added “spotify” in the service list of sonos app).
Just in case, my complete config:
Sonos have a static IP (however I think this is relevant only for zeroconf_device_connect)
Sonos App (on my mobile device) contains “spotify” in the service list
HA, SpotifyPlus conf:
Screen 1:
default player device id: <sonos name + id>
other inputs: empty / default
Screen 2: I filled loginId, Username, and password (using tips in SpotifyPlus documentation to get the loginId, which happened to be the same as my username)
And to be complete, before calling player_media_play_context, i’m setting the volume (just in case setting the volume wake the sonos up, but I don’t think so)
Ya, you have to have the Spotify service installed via the Sonos official app in order to transfer playback to the device via SpotifyPlus. I always just assumed people would have that installed if they were using Spotify on Sonos. I will add that note to the documentation wiki.
I am not sure how you had HA Spotify working with Sonos before though. The only scenario where that could possibly work is that you transfer play to the Sonos device via the Spotify Mobile App, then you could use the HA Spotify integration to control the player once it was active. I still wonder about that though, because Sonos uses a designated client ID to control the device, and you have to authorize that client ID in some way via OAuth authentication (when setting up the Spotify service via the Sonos app).
Anyway, it sounds like it’s working for you now as far as Sonos play is concerned.
As for the token generator script and API rate limit exceeded … I reran my script yesterday and it had no issues. I’m wondering if it might be related to a specific country or product setting? For example, maybe they are making changes to their European market, which cause it to fail for European customers but not US customers. I’m still not sure what is going on with that, as I cannot reproduce the issue, and only a few users have reported the problem.
@DGerding-2307@fload@tmarly
I finally figured out the issue with the AuthTokenGenerator, 429 API rate limit exceeded error.
As it turns out, Spotify made some unannounced changes to the Spotify Web API on or around 2025/12/15. After that date, a “429 - API rate limit exceeded” error will be returned when the Spotify Desktop App client id authorization token is used to retrieve data from the Spotify Web API.
The AuthTokenGenerator script process generates a Spotify auth token for the Spotify Desktop App client id, which will then be used to activate Google Cast devices by launching the Spotify Cast App on the device via the Cast protocol. That is the ONLY function that this token can be used for. The script was failing (with 429 error) because it was trying to retrieve the current user information AFTER generating the auth token; the information retrieved was only used to get the user display name, which is not really required for the process.
I corrected the code to account for this.
What You Need To Do
You only need to do this if you experience one of the following errors:
Spotify Desktop Player authorization token was not found in the token cache file when trying to activate a Google Cast device.
429 - API rate limit exceeded when trying to execute the AuthTokenGenerator.py script.
The AuthTokenGenerator.py script and spotifywebapipython library need to be updated to the latest version. Follow the instructions in the SpotifyPlus Python Environment Setup Instructions wiki guide, making note of the following:
make sure you issue the pip install spotifywebapipython -U command, which will update the library to the 1.0.258 version.
Has anyone experience of using play_show_latest_episode: false? I have this set on a automation which I understood would mean that when I run the automation to play a particular podcast it would resume from the last played episode of that podcast and from wherever that podcast was last played to. The automation seems to be behaving as if this is set to true as it just started the latest episode of that show from the start.
@peterspierson
Spotifyplus author here … the play_show_latest_episode argument of the Player Media Play Context service should resume playing of the podcast episode that was previously played if the value is false.
What does your player_media_play_context service call look like? And what is the context_uri value you are passing in (if using a variable)?
If play_show_latest_episode: true is specified (restart from latest episode), then the underlying calls go through the following sequence:
If play_show_latest_episode: false is specified (restart from last position of episode), then it just uses the player_media_play_context call after setting the shuffle mode (if shuffle: true was specified). I’m wondering if the shuffle: true might be causing the issue?
Hi all–I’m chasing an odd one here and hoping someone might have an idea of where I might look next? I have a script that runs each weekday morning and plays one of two playlists depending on whether my wife is home or not. The playback is through the Spotify app running on a Roku Ultra. MOST of the time the script runs without issue and as expected. Sometimes it throws an error and playback never starts. The error I am getting is “Error executing script. Error for call_service at pos 13: Player command failed: Restriction violated”. Since SpotifyPlus is working as expected in every other automation and player card I have, I suspect it is NOT an issue with the integration–but I am at a total loss as to why this error would present itself sort of randomly. Anyone seen anything like this before? Spotty Spotify API?