{"record":{"id":"0e42e03ca3748a8f","repo":"Significant-Gravitas/AutoGPT","slug":"invalid-api-key","errorCode":null,"errorMessage":"Invalid API key","messagePattern":"Invalid API key","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"autogpt_platform/backend/backend/api/external/middleware.py","lineNumber":28,"sourceCode":"    OAuthAccessTokenInfo,\n    validate_access_token,\n)\n\napi_key_header = APIKeyHeader(name=\"X-API-Key\", auto_error=False)\nbearer_auth = HTTPBearer(auto_error=False)\n\n\nasync def require_api_key(api_key: str | None = Security(api_key_header)) -> APIKeyInfo:\n    \"\"\"Middleware for API key authentication only\"\"\"\n    if api_key is None:\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED, detail=\"Missing API key\"\n        )\n\n    api_key_obj = await validate_api_key(api_key)\n\n    if not api_key_obj:\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED, detail=\"Invalid API key\"\n        )\n\n    return api_key_obj\n\n\nasync def require_access_token(\n    bearer: HTTPAuthorizationCredentials | None = Security(bearer_auth),\n) -> OAuthAccessTokenInfo:\n    \"\"\"Middleware for OAuth access token authentication only\"\"\"\n    if bearer is None:\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED,\n            detail=\"Missing Authorization header\",\n        )\n\n    try:\n        token_info, _ = await validate_access_token(bearer.credentials)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/external/middleware.py#L10-L46","documentation":"Error \"Invalid API key\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/external/middleware.py:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the API key for typos and that it has not been revoked or expired.","Generate a new API key and update the client configuration."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}