The problem
I have installed v5.0.0-b30.
When I try to provide the sp_dc and sp_key values at configuration, an “Invalid TOTP” error is thrown. I tried three or four times to make sure I wasn’t doing something wrong.
System Information
| version |
core-2025.3.2 |
| installation_type |
Home Assistant OS |
| dev |
false |
| hassio |
true |
| docker |
true |
| user |
root |
| virtualenv |
false |
| python_version |
3.13.2 |
| os_name |
Linux |
| os_version |
6.6.62-haos-raspi |
| arch |
aarch64 |
| timezone |
America/Indianapolis |
| config_dir |
/config |
Home Assistant Community Store
| GitHub API |
ok |
| GitHub Content |
ok |
| GitHub Web |
ok |
| HACS Data |
ok |
| GitHub API Calls Remaining |
4956 |
| Installed Version |
2.0.5 |
| Stage |
running |
| Available Repositories |
1589 |
| Downloaded Repositories |
3 |
Home Assistant Cloud
| logged_in |
true |
| subscription_expiration |
February 6, 2026 at 7:00 PM |
| relayer_connected |
true |
| relayer_region |
us-east-1 |
| remote_enabled |
true |
| remote_connected |
true |
| alexa_enabled |
false |
| google_enabled |
true |
| cloud_ice_servers_enabled |
true |
| remote_server |
us-east-1-14.ui.nabu.casa |
| certificate_status |
ready |
| instance_id |
30f273ad337a4e8eb1985a895eb08817 |
| can_reach_cert_server |
ok |
| can_reach_cloud_auth |
ok |
| can_reach_cloud |
ok |
Home Assistant Supervisor
| host_os |
Home Assistant OS 14.2 |
| update_channel |
stable |
| supervisor_version |
supervisor-2025.03.2 |
| agent_version |
1.6.0 |
| docker_version |
27.2.0 |
| disk_total |
57.8 GB |
| disk_used |
6.9 GB |
| healthy |
true |
| supported |
true |
| host_connectivity |
true |
| supervisor_connectivity |
true |
| ntp_synchronized |
true |
| virtualization |
|
| board |
rpi5-64 |
| supervisor_api |
ok |
| version_api |
ok |
| installed_addons |
Studio Code Server (5.18.3), AdGuard Home (5.2.5) |
Dashboards
| dashboards |
2 |
| resources |
0 |
| views |
0 |
| mode |
storage |
Network Configuration
| adapters |
lo (disabled), end0 (enabled, default, auto), hassio (disabled), docker0 (disabled), veth600d57f (disabled), veth7f095a5 (disabled), veth5cc2d7a (disabled), veth94ad141 (disabled), veth78616a5 (disabled), veth8e63670 (disabled), veth6fa8856 (disabled) |
| ipv4_addresses |
lo (127.0.0.1/8), end0 (192.168.1.141/24), hassio (172.30.32.1/23), docker0 (172.30.232.1/23), veth600d57f (), veth7f095a5 (), veth5cc2d7a (), veth94ad141 (), veth78616a5 (), veth8e63670 (), veth6fa8856 () |
| ipv6_addresses |
lo (::1/128), end0 (2603:900a:1bf0:b350::1099/128, 2603:900a:1bf0:b350:2c2d:cbb1:d9d1:8a47/64, fe80::8aee:29c4:2077:2413/64), hassio (fe80::42:c8ff:fe9c:da28/64), docker0 (fe80::42:f5ff:fed5:941f/64), veth600d57f (fe80::5c0b:14ff:fea3:ab72/64), veth7f095a5 (fe80::d06a:95ff:fe56:743b/64), veth5cc2d7a (fe80::2cb1:48ff:fec2:bca9/64), veth94ad141 (fe80::9883:e2ff:fe20:d763/64), veth78616a5 (fe80::a83a:8aff:fecf:747d/64), veth8e63670 (fe80::4c8e:c7ff:fe6f:7efe/64), veth6fa8856 (fe80::545b:3cff:fe81:c712/64) |
| announce_addresses |
192.168.1.141, 2603:900a:1bf0:b350::1099, 2603:900a:1bf0:b350:2c2d:cbb1:d9d1:8a47, fe80::8aee:29c4:2077:2413 |
Recorder
| oldest_recorder_run |
March 2, 2025 at 10:25 PM |
| current_recorder_run |
March 14, 2025 at 9:54 AM |
| estimated_db_size |
28.18 MiB |
| database_engine |
sqlite |
| database_version |
3.48.0 |
Spotify
| api_endpoint_reachable |
ok |
What type of installation are you running?
Home Assistant OS
Diagnostics information
Spotcast was successfully installed, so HACS logs are irrelevant. The error is thrown during configuration, so debug mode can’t be configured for Spotcast.
However, I have provided the HA logs:
home-assistant_2025-03-14T14-01-02.273Z.log
I’m not contributing to this project, don’t have the skills, but I just wanted to hop on here and say thank you to all who are working on finding a fix. My family’s wakeup routine, and many others around the world, are depending on this 😂
official
v4.0.1is released. Closing this ticket…Finally
For anyone getting errors yes currently spotcast will be broken. They implemented a new multi-factor scheme and we are not compatible with it. Until a new version of spotcast is released expect your it to not work
So Spotify changed their message on the access_token endpoint:
As reported in #530 they now report:
Failed to set up: 400:
I would actively suggest right now for anyone to deactivate their spotcast integration for the time being until we have clearer picture of what actions Spotify are willing to take at this point.
Soon™
@bkeys818 looks like Spotify started to add a 2 factor authentifaction with logins to the web browser. Just checked and its not just the setup that is broken, current install are also breaking. This might take some times before being able to fix, if possible
@misiektoja thanks for the gist. Turns out in my case, I had a small mistake in the hex string format function causing to cascade into a bad secret.
I seem to be able to get an access token now. Should be on the right track for a fix
Two new builds have been released
v4.0.1-b1andv5.0.0-b33. Both added a better parsing of authentication failure in case of error 302.a beta version (build 31) was released with the TOTP fix. I’ll wait for reviews of the beta version and then release the production version.
I’ll take a stab at it later today 👍
I would like to thank you for your investment, which is very, very much appreciated !
Could this be the reason I started to get “Could not get spotify token” errors a couple hours ago?
Released
build 32to solve the issue where the_test_tokenmethod was not awaited. The process should now truly test that the token provided is a valid one.@bendikrb thanks for the info, I’ll have time during the week, so I’ll check if I can find a fix.
A build candidate
v4.0.1-b0has been pushed to prerelease. Working well on my end. I’ll wait a bit for reports from other user before officially releasing it as production build@Kagey-cmd don’t worry I’ll be releasing a V4 version I just wanted to stress test in the dev channel first. I’m working on the V4 version now.
Same here thanks the work guys, really appreciate it, as this kind of thing is way above my understanding.
On Tue, 18 Mar 2025, 12:56 PilotSteveNW, @.***> wrote:
@bendikrb thanks for the info, they might be using multiple schemes for the details. I’ll try to test everything when I’m back home after work
When can we expect a fix for this?
I just wanted to confirm to everyone, you don’t have to move to the V5 beta, I only used that version as a testing ground, I will be create an update for V4 as well after I have confirmation that the fix is working well in the beta.
@thlucas1 Yeah the retry scheme was already pointed out by Spotube developer.
Personally the delay wasn’t necessary, also I moved to the current query format which you can find in the current dev version (on phone hard to provide link).
I have a feeling that using the scheme you provided might result some times in the wrong token being provided while the new one with a server and client TOTP is the one used by spotify at the moment of writing.
Anyway I’ll be releasing soon in the dev branch my current solution is working well and using an Api call to test the token works well.
From reddit, I was pointed out to this fix from spotube. Looks like a cipher has to be solved in order to get the token now.
https://github.com/KRTirtho/spotube/commit/59f298a935c87077a6abd50656f8a4ead44bd979
Hi everybody, thanks a lot for the fix. It seems spotcast.start des not exist anymore after updating. I need to use play_media instead. Do you confirm?
Thank you 🙂
Guys, just read the doc if you want to test v5 but don’t ask general questions here.
The fix works for me as well. Thank you very much.
@XalaTheShepard try spotcast.play_media
Thank you so much ! My family is counting on you. You rock 🥳.
I also started getting “Could not get spotify token” errors from v4. That’s why I initially tried to install the beta.
v4.0.1-b1 is working perfectly for me too on amazon echo + google nest. Thanks!
@Pirol62 please this is not a forum thread this is bug ticket if you have question open another ticket this is polluting discussion around a bug.
There are lots of reasons for the architecture range and you should expect them when a project goes through a full refactor. If you have question aboit the V5 refactor ask them in the V5 refactor discussion ticket please
Hi, after a lot of recoding (when the spotify card stopped working I developed my own spotify dashboard), I got it working now. Creating a second oAuth was easy and worked perfectly. Thanks for your hard work so quick! One minor issue: But after the upgrade to 5.x HA doesn’t finish the reload process anymore. The popup which shows the progress of the loading procedure never diappears again so I have to close it manually. Does anyone else have this behavior?
And last but not least a question: You decided, to create own devices for the media players. As I have a lot of echos and use an input_select to choose the target player group, I had to write a mapper in order to translate the origin media players into the spotcast ones:
and then i.e:
Why did you choose that way?. My fear is, that when spotify rescans or reloads the device list, that all identifiers will be changed.
@thlucas1 thanks yeah I wanted to move to parsing the query portion and look for the key anyway, that way it’s going to be way simpler even if the format changes again
There’s
randomin the documentation: https://github.com/fondberg/spotcast/blob/dev/docs/services/play_media.mdPlease don’t ask more general questions about v5 in this thread, there is a dedicated one here.
Edit: where you are cross-posting already…
@XalaTheShepard yes the services have changed quite a bit in V5. I would suggest you read the release note and the documentation. Edit: More specifically, the service definitions
V5 has been in testing since November. As per my last comment in this ticket. I only used it as a testing bed for the fix. If you still prefer to stay on V4, the fixed version should be available soon.
Hi there, I spent some time going through the gist shared by @bendikrb, attempted to replicate the behavior in Spotube’s Dart code, made some logical changes and I got it working:
PoC: spotify_monitor_totp_test.py, more info in the Debugging Tools section of the spotify_monitor project.
It might require some cleaning as I played with different options. BTW, sp_key is not needed.
EDIT: updated link
For reference, check how we handle this error in Spotube side: https://github.com/KRTirtho/spotube/blob/0ec9f3535bf9c927d81cb67e62aa35da36648c98/lib/provider/spotify/spotify.dart#L81-L110
There all a lot of functionalities that relies on the cookie. The most important of them is the registration of Chromecast device. The public Api doesn’t allow for it.
This was discussed in more details #452