home-assistant/core · error · ConfigEntryAuthFailed
Invalid API token.
Error message
Invalid API token.
What it means
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.
Source
Thrown at homeassistant/components/blue_current/__init__.py:67
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Blue Current."""
async_setup_services(hass)
return True
async def async_setup_entry(
hass: HomeAssistant, config_entry: BlueCurrentConfigEntry
) -> bool:
"""Set up Blue Current as a config entry."""
client = Client()
api_token = config_entry.data[CONF_API_TOKEN]
connector = Connector(hass, config_entry, client)
try:
await client.validate_api_token(api_token)
except InvalidApiToken as err:
raise ConfigEntryAuthFailed("Invalid API token.") from err
except BlueCurrentException as err:
raise ConfigEntryNotReady from err
config_entry.async_create_background_task(
hass, connector.run_task(), "blue_current-websocket"
)
await client.wait_for_charge_points()
config_entry.runtime_data = connector
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
return True
async def async_unload_entry(
hass: HomeAssistant, config_entry: BlueCurrentConfigEntry
) -> bool:
"""Unload the Blue Current config entry."""
View on GitHub (pinned to 58a3fdb3ea)
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
Defensive patterns
Strategy: validation
Validate before calling
# Before setup, sanity-check the token shape (defensive; real check is server-side)
api_token = config_entry.data[CONF_API_TOKEN]
if not api_token or api_token != api_token.strip():
raise ValueError("API token empty or has surrounding whitespace") Try / catch
try:
await client.validate_api_token(api_token)
except InvalidApiToken as err:
raise ConfigEntryAuthFailed("Invalid API token.") from err Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/a37b396ba21bc51b.
Report an issue: GitHub.