From 7f0da8a6d899b58ad883b1adaf3577b63fa3123d Mon Sep 17 00:00:00 2001 From: "Torgeir S." Date: Sat, 16 Sep 2023 17:33:15 +0200 Subject: [PATCH] check for authfailed and 302 status --- custom_components/spotcast/spotcast_controller.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/custom_components/spotcast/spotcast_controller.py b/custom_components/spotcast/spotcast_controller.py index e8d02ca6..44683c62 100644 --- a/custom_components/spotcast/spotcast_controller.py +++ b/custom_components/spotcast/spotcast_controller.py @@ -208,6 +208,14 @@ async def start_session(self): allow_redirects=False, headers=headers ) as response: + if (response.status == 302 and response.headers['Location'] == '/get_access_token?reason=transport&productType=web_player&_authfailed=1'): + _LOGGER.error( + "Unsuccessful token request, received code 302 and " + "Location header %s. sp_dc and sp_key could be " + "expired. Please update in config.", + response.headers['Location'] + ) + raise HomeAssistantError("Expired sp_dc, sp_key") if (response.status != 200): _LOGGER.info( "Unsuccessful token request, received code %i",