{"record":{"id":"baa60436f19df2cb","repo":"home-assistant/core","slug":"invalid-credentials-baa604","errorCode":null,"errorMessage":"invalid_credentials","messagePattern":"invalid_credentials","errorType":"exception","errorClass":"ConfigEntryAuthFailed","httpStatus":null,"severity":"error","filePath":"homeassistant/components/backblaze_b2/__init__.py","lineNumber":57,"sourceCode":"    b2_api = B2Api(info)\n\n    def _authorize_and_get_bucket_sync() -> Bucket:\n        \"\"\"Synchronously authorize the Backblaze B2 account and retrieve the bucket.\n\n        This function runs in the event loop's executor as\n        b2sdk operations are blocking.\n        \"\"\"\n        b2_api.authorize_account(\n            BACKBLAZE_REALM,\n            entry.data[CONF_KEY_ID],\n            entry.data[CONF_APPLICATION_KEY],\n        )\n        return b2_api.get_bucket_by_name(entry.data[CONF_BUCKET])\n\n    try:\n        bucket = await hass.async_add_executor_job(_authorize_and_get_bucket_sync)\n    except exception.Unauthorized as err:\n        raise ConfigEntryAuthFailed(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_credentials\",\n        ) from err\n    except exception.RestrictedBucket as err:\n        create_bucket_access_restricted_issue(hass, entry, err.bucket_name)\n        raise ConfigEntryNotReady(\n            translation_domain=DOMAIN,\n            translation_key=\"restricted_bucket\",\n            translation_placeholders={\n                \"restricted_bucket_name\": err.bucket_name,\n            },\n        ) from err\n    except exception.NonExistentBucket as err:\n        create_bucket_not_found_issue(hass, entry, entry.data[CONF_BUCKET])\n        raise ConfigEntryNotReady(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_bucket_name\",\n        ) from err","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/backblaze_b2/__init__.py#L39-L75","documentation":"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.","triggerScenarios":"_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).","commonSituations":"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).","solutions":["Follow the reauth prompt and re-enter the keyID and applicationKey","Verify the key exists in the Backblaze B2 console and has not been revoked","Ensure the application key has capabilities: listBuckets, readFiles, writeFiles, deleteFiles (and listKeys if applicable) for the target bucket","Confirm keyID matches the key (application keys have their own keyID, not the account keyID)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import b2sdk.v2.exception as b2exc\n\ndef is_unauthorized(err: BaseException) -> bool:\n    return isinstance(err, b2exc.Unauthorized)","tryCatchPattern":"try:\n    bucket = await hass.async_add_executor_job(_authorize_and_get_bucket_sync)\nexcept exception.Unauthorized as err:\n    raise ConfigEntryAuthFailed(translation_domain=DOMAIN, translation_key=\"invalid_credentials\") from err","preventionTips":["Create a dedicated application key with exactly the needed bucket and capabilities","Copy keyID and key together from the Backblaze console to avoid transcription errors","Revoke-and-rotate keys through the reauth flow, not by editing entry data"],"tags":["backblaze","b2","auth","config-entry"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}