unclecode/crawl4ai · error · HTTPException

Admin scope required

Error message

Admin scope required

What it means

Error "Admin scope required" thrown in unclecode/crawl4ai.

Source

Thrown at deploy/docker/auth.py:140

    """Backward-compatible dependency factory.

    Auth enforcement now lives in the AuthGateMiddleware (the outermost ASGI
    layer); by the time any route dependency runs, the request was already
    authenticated by the gate or rejected with 401. This dependency simply
    surfaces the validated principal to handlers that declared `_td`.
    """

    def _principal(request: Request) -> Optional[Dict]:
        return get_principal(request)

    return _principal


def require_admin(request: Request) -> Dict:
    """Dependency: require an admin-scope principal (destructive actions)."""
    principal = get_principal(request)
    if not principal or principal.get("scope") != "admin":
        raise HTTPException(status_code=403, detail="Admin scope required")
    return principal


class TokenRequest(BaseModel):
    email: EmailStr
    api_token: Optional[str] = None

View on GitHub (pinned to 7e80152142)

Solutions

  1. Authenticate with a token that has the admin scope for this endpoint.
  2. Ask the server operator to grant admin scope to your token.

Example fix

Authorization: Bearer <admin-scoped-token>

When it happens

Trigger: Thrown at deploy/docker/auth.py:140 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14). Data as JSON: /api/errors/cc568832a979ef6d. Report an issue: GitHub.