{"record":{"id":"f81b4e74e25ffa4e","repo":"home-assistant/core","slug":"invalid-auth","errorCode":"invalid_auth","errorMessage":"Invalid authentication credentials: {error}","messagePattern":"Invalid authentication credentials: (.+?)","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/alexa_devices/coordinator.py","lineNumber":53,"sourceCode":"from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed\nfrom homeassistant.util import slugify\n\nfrom .const import CONF_LOGIN_DATA, DOMAIN, LOGGER\n\nSCAN_INTERVAL = 300\n\n\n@asynccontextmanager\nasync def alexa_api_call(\n    coordinator: DataUpdateCoordinator | None = None,\n) -> AsyncGenerator[None]:\n    \"\"\"Handle common Alexa API exceptions as HomeAssistantError.\"\"\"\n    try:\n        yield\n    except CannotAuthenticate as err:\n        if coordinator:\n            coordinator.last_update_success = False\n        raise HomeAssistantError(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_auth\",\n            translation_placeholders={\"error\": repr(err)},\n        ) from err\n    except CannotConnect as err:\n        if coordinator:\n            coordinator.last_update_success = False\n        raise HomeAssistantError(\n            translation_domain=DOMAIN,\n            translation_key=\"cannot_connect_with_error\",\n            translation_placeholders={\"error\": repr(err)},\n        ) from err\n    except (CannotRetrieveData, ValueError) as err:\n        if coordinator:\n            coordinator.last_update_success = False\n        raise HomeAssistantError(\n            translation_domain=DOMAIN,\n            translation_key=\"cannot_retrieve_data_with_error\",","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/alexa_devices/coordinator.py#L35-L71","documentation":"Raised as a HomeAssistantError (translation key alexa_devices/invalid_auth) when the underlying alexapy client signals CannotAuthenticate during an Alexa API call wrapped by the alexa_api_call context manager. It means Amazon rejected the stored authentication cookies/tokens, so the API call cannot proceed. The coordinator is also flagged as failed (last_update_success = False) so entities show unavailable.","triggerScenarios":"Any coordinator or service code path that runs inside `async with alexa_api_call(...)` (entity actions, media commands, notifications) when alexapy raises CannotAuthenticate — typically expired Amazon cookies, a changed account password, or Amazon presenting a CAPTCHA/2FA challenge during the request.","commonSituations":"Long-running installations whose Amazon session cookies expire (~every few weeks), users who changed their Amazon password or revoked sessions, logins from a new region triggering Amazon security challenges, or two-factor prompts that the stored session cannot answer.","solutions":["Trigger the reauth config flow for the alexa_devices config entry (UI will show a reauthentication prompt) and log in to Amazon again to store fresh cookies","Verify the Amazon account password was not changed and no suspicious-login lockout exists on the Amazon side","If 2FA/CAPTCHA is involved, complete the interactive login in the config flow so the OTP is captured","Restart Home Assistant after successful reauth so coordinators rebuild with the new session"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    async with alexa_api_call():\n        await coordinator.api.some_call(...)\nexcept HomeAssistantError as err:\n    if err.translation_key == \"invalid_auth\":\n        # surface reauth to the user; stop retrying\n        _LOGGER.warning(\"Alexa session expired: %s\", err)\n    else:\n        raise","preventionTips":["Keep the Amazon session fresh by letting the integration poll regularly; long disables increase cookie expiry odds","Complete reauth promptly when the entry shows an auth error instead of retrying service calls","Avoid changing the Amazon account password without planning to re-authenticate the integration"],"tags":["alexa-devices","authentication","session-expiry","homeassistant"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}