{"record":{"id":"a37b396ba21bc51b","repo":"home-assistant/core","slug":"invalid-api-token","errorCode":null,"errorMessage":"Invalid API token.","messagePattern":"Invalid API token\\.","errorType":"exception","errorClass":"ConfigEntryAuthFailed","httpStatus":null,"severity":"error","filePath":"homeassistant/components/blue_current/__init__.py","lineNumber":67,"sourceCode":"async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:\n    \"\"\"Set up Blue Current.\"\"\"\n\n    async_setup_services(hass)\n    return True\n\n\nasync def async_setup_entry(\n    hass: HomeAssistant, config_entry: BlueCurrentConfigEntry\n) -> bool:\n    \"\"\"Set up Blue Current as a config entry.\"\"\"\n    client = Client()\n    api_token = config_entry.data[CONF_API_TOKEN]\n    connector = Connector(hass, config_entry, client)\n\n    try:\n        await client.validate_api_token(api_token)\n    except InvalidApiToken as err:\n        raise ConfigEntryAuthFailed(\"Invalid API token.\") from err\n    except BlueCurrentException as err:\n        raise ConfigEntryNotReady from err\n    config_entry.async_create_background_task(\n        hass, connector.run_task(), \"blue_current-websocket\"\n    )\n\n    await client.wait_for_charge_points()\n    config_entry.runtime_data = connector\n    await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)\n\n    return True\n\n\nasync def async_unload_entry(\n    hass: HomeAssistant, config_entry: BlueCurrentConfigEntry\n) -> bool:\n    \"\"\"Unload the Blue Current config entry.\"\"\"\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/blue_current/__init__.py#L49-L85","documentation":"ConfigEntryAuthFailed('Invalid API token.') raised during blue_current setup when client.validate_api_token(api_token) raises InvalidApiToken. The charge point API token stored in the config entry was rejected by the Blue Current cloud, so HA demands re-entry of credentials instead of retrying.","triggerScenarios":"First setup or reload of the Blue Current integration with a token that is wrong (copy/paste error), revoked from the Blue Current portal, or expired. validate_api_token performs an authenticated WebSocket/REST probe during async_setup_entry.","commonSituations":"Token rotated in the Blue Current customer portal but not updated in HA; whitespace/newline pasted with the token; account token revoked when a new one was generated.","solutions":["Re-enter the integration and paste a freshly generated API token from the Blue Current portal","Copy the token without leading/trailing whitespace or newlines","If the new token is also rejected, verify the account itself is active in the portal"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Before setup, sanity-check the token shape (defensive; real check is server-side)\napi_token = config_entry.data[CONF_API_TOKEN]\nif not api_token or api_token != api_token.strip():\n    raise ValueError(\"API token empty or has surrounding whitespace\")","typeGuard":null,"tryCatchPattern":"try:\n    await client.validate_api_token(api_token)\nexcept InvalidApiToken as err:\n    raise ConfigEntryAuthFailed(\"Invalid API token.\") from err","preventionTips":["Paste tokens with trailing-newline trimming (token.strip())","Regenerate the token in the Blue Current portal if it was unused for a long period","Store tokens via !secrets to avoid YAML quoting corruption"],"tags":["blue-current","auth","api-token","config-entry"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}