{"record":{"id":"07c9980a8678db06","repo":"Significant-Gravitas/AutoGPT","slug":"missing-api-key","errorCode":null,"errorMessage":"Missing API key","messagePattern":"Missing API key","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"autogpt_platform/backend/backend/api/external/middleware.py","lineNumber":21,"sourceCode":"from prisma.enums import APIKeyPermission\n\nfrom backend.data.auth.api_key import APIKeyInfo, validate_api_key\nfrom backend.data.auth.base import APIAuthorizationInfo\nfrom backend.data.auth.oauth import (\n    InvalidClientError,\n    InvalidTokenError,\n    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:","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/external/middleware.py#L3-L39","documentation":"Error \"Missing API key\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/external/middleware.py:21 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the API key in the expected header (e.g. 'X-API-Key') with the request.","Create an API key in your account settings if you do not have one."],"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"}