wp_access_token error
See original GitHub issueI cannot play music anymore. I’m using version v2.2 of Spotcast and Home Assistent 0.99.3.
I get the following error using services under developertools in Home Assistent and using spotify-card.
Log Details (ERROR) Sun Sep 29 2019 17:33:52 GMT+0200 (centraleuropeisk sommartid) "name='wp_access_token', domain=None, path=None" Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service connection.context(msg), File "/usr/src/homeassistant/homeassistant/core.py", line 1234, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File "/usr/src/homeassistant/homeassistant/core.py", line 1261, in _execute_service await self._hass.async_add_executor_job(handler.func, service_call) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/spotcast/__init__.py", line 162, in start_casting access_token, expires = get_spotify_token(username=user, password=pwd) File "/config/custom_components/spotcast/__init__.py", line 85, in get_spotify_token data = st.start_session(username, password) File "/usr/local/lib/python3.7/site-packages/spotify_token.py", line 70, in start_session access_token, expiration_date = _get_access_token(session, cookies) File "/usr/local/lib/python3.7/site-packages/spotify_token.py", line 42, in _get_access_token access_token = response.cookies['wp_access_token'] File "/usr/local/lib/python3.7/site-packages/requests/cookies.py", line 328, in __getitem__ return self._find_no_duplicates(name) File "/usr/local/lib/python3.7/site-packages/requests/cookies.py", line 399, in _find_no_duplicates raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path)) KeyError: "name='wp_access_token', domain=None, path=None"
This is added to configuration.yaml
spotcast:
username: myusername password: mypassword accounts: fredrik: username: myusername password: mypassword philip: username: myusername2 password: mypassword2
custom-cards:spotify-card
client_id: mycliendid limit: 25 random_song: true transfer_playback: true type: ‘custom:spotify-card’
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:31 (6 by maintainers)
Top GitHub Comments
Looks like Spotify has changed their authentication so
wp_access_token
no longer is return as a cookie after logging in as defined in https://github.com/enriquegh/spotify-webplayer-token/blob/c8ebf5811640cc78eb560ac725cb7d944c63f400/spotify_token.py#L42 which spotcast depends on. Confirmed that by sniffing looking at the traffic when logging into https://accounts.spotify.com/login It looks like they instead use a bunch of cookies (sp_ac, sp_key and sp_dc). I’m not sure if they existed before too and if any of them has the value of the access token. This will have to be investigated more. I can try to find time in a few days if @fondberg doesnt beat me to it.I assume its not possible to obtain a full access token using any official APIs, @fondberg?
Oh no! If I am correct this means Spotify changed the way a browser token is retrieved. That is bad as this library uses the unofficial way to get a token because it is required for chromecast devices. I will need to investigate this…