home-assistant/core · error · InputValidationError

invalid_auth

invalid_auth

Error message

invalid_auth

What it means

Raised in the Bond config flow when BondHub.setup() fails with an aiohttp ClientResponseError whose status is HTTP 401 UNAUTHORIZED. The hub answered, but the access token (CONF_ACCESS_TOKEN) was rejected. It is surfaced as InputValidationError('invalid_auth') so the UI prompts for new credentials.

Source

Thrown at homeassistant/components/bond/config_flow.py:63


async def _validate_input(hass: HomeAssistant, data: dict[str, Any]) -> tuple[str, str]:
    """Validate the user input allows us to connect."""

    bond = Bond(
        data[CONF_HOST],
        data[CONF_ACCESS_TOKEN],
        session=async_get_clientsession(hass),
        requestor_uuid=RequestorUUID.HOME_ASSISTANT,
    )
    try:
        hub = BondHub(bond, data[CONF_HOST])
        await hub.setup(max_devices=1)
    except ClientConnectionError as error:
        raise InputValidationError("cannot_connect") from error
    except ClientResponseError as error:
        if error.status == HTTPStatus.UNAUTHORIZED:
            raise InputValidationError("invalid_auth") from error
        raise InputValidationError("unknown") from error
    except Exception as error:
        _LOGGER.exception("Unexpected exception")
        raise InputValidationError("unknown") from error

    # Return unique ID from the hub to be stored in the config entry.
    if not hub.bond_id:
        raise InputValidationError("old_firmware")

    return hub.bond_id, hub.name


class BondConfigFlow(ConfigFlow, domain=DOMAIN):
    """Handle a config flow for Bond."""

    VERSION = 1

    def __init__(self) -> None:

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Open the Bond app, go to hub Settings > Local API Access / Integrations, and copy the current token exactly.
  2. Re-enter host + token in the config flow and resubmit.
  3. If the token was regenerated, regenerate deliberately and update every client using the old one.
Defensive patterns

Strategy: validation

Validate before calling

async def token_valid(host: str, token: str, session) -> bool:
    resp = await session.get(
        f"http://{host}:30001/v2/devices",
        headers={"BOND-Token": token},
    )
    return resp.status != 401

Try / catch

try:
    hub = BondHub(bond); await hub.setup(max_devices=1)
except ClientResponseError as err:
    if err.status == HTTPStatus.UNAUTHORIZED:
        # prompt user to re-enter the access token
        ...

Prevention

When it happens

Trigger: Submitting the config form with a wrong, revoked, or typo'd Bond access token; a token regenerated in the Bond app after it was saved in Home Assistant; token copied with whitespace or missing characters.

Common situations: Token reset from the Bond app (Settings > Local API key), copy/paste truncation, using the cloud token instead of the local API token.

Related errors


AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14). Data as JSON: /api/errors/9463b136322facb0. Report an issue: GitHub.