home-assistant/core · error · ConfigEntryAuthFailed

invalid_credentials

Error message

invalid_credentials

What it means

Raised as ConfigEntryAuthFailed (translation key invalid_credentials) when the blocking b2_api.authorize_account() call in setup fails with b2sdk v2 exception.Unauthorized. The Backblaze B2 keyID/applicationKey pair was rejected, so HA starts a reauth flow instead of retrying.

Source

Thrown at homeassistant/components/backblaze_b2/__init__.py:57

    b2_api = B2Api(info)

    def _authorize_and_get_bucket_sync() -> Bucket:
        """Synchronously authorize the Backblaze B2 account and retrieve the bucket.

        This function runs in the event loop's executor as
        b2sdk operations are blocking.
        """
        b2_api.authorize_account(
            BACKBLAZE_REALM,
            entry.data[CONF_KEY_ID],
            entry.data[CONF_APPLICATION_KEY],
        )
        return b2_api.get_bucket_by_name(entry.data[CONF_BUCKET])

    try:
        bucket = await hass.async_add_executor_job(_authorize_and_get_bucket_sync)
    except exception.Unauthorized as err:
        raise ConfigEntryAuthFailed(
            translation_domain=DOMAIN,
            translation_key="invalid_credentials",
        ) from err
    except exception.RestrictedBucket as err:
        create_bucket_access_restricted_issue(hass, entry, err.bucket_name)
        raise ConfigEntryNotReady(
            translation_domain=DOMAIN,
            translation_key="restricted_bucket",
            translation_placeholders={
                "restricted_bucket_name": err.bucket_name,
            },
        ) from err
    except exception.NonExistentBucket as err:
        create_bucket_not_found_issue(hass, entry, entry.data[CONF_BUCKET])
        raise ConfigEntryNotReady(
            translation_domain=DOMAIN,
            translation_key="invalid_bucket_name",
        ) from err

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Follow the reauth prompt and re-enter the keyID and applicationKey
  2. Verify the key exists in the Backblaze B2 console and has not been revoked
  3. Ensure the application key has capabilities: listBuckets, readFiles, writeFiles, deleteFiles (and listKeys if applicable) for the target bucket
  4. Confirm keyID matches the key (application keys have their own keyID, not the account keyID)
Defensive patterns

Strategy: try-catch

Type guard

import b2sdk.v2.exception as b2exc

def is_unauthorized(err: BaseException) -> bool:
    return isinstance(err, b2exc.Unauthorized)

Try / catch

try:
    bucket = await hass.async_add_executor_job(_authorize_and_get_bucket_sync)
except exception.Unauthorized as err:
    raise ConfigEntryAuthFailed(translation_domain=DOMAIN, translation_key="invalid_credentials") from err

Prevention

When it happens

Trigger: _authorize_and_get_bucket_sync runs authorize_account(BACKBLAZE_REALM, key_id, application_key) via executor; b2sdk returns Unauthorized (401 unauthorized for bad credentials, or a valid application key with wrong capabilities).

Common situations: Application key deleted or regenerated in the Backblaze console, typo in keyID, using a master key after it was disabled, key lacks the required capabilities (listBuckets/readFiles/writeFiles).

Related errors


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