Significant-Gravitas/AutoGPT · error · HTTPException

User ID not found in token

Error message

User ID not found in token

What it means

Error "User ID not found in token" thrown in Significant-Gravitas/AutoGPT.

Source

Thrown at autogpt_platform/autogpt_libs/autogpt_libs/auth/jwt_utils.py:172

                cache_keys=True,
                lifespan=JWKS_CACHE_LIFESPAN_SECONDS,
                # PyJWT defaults to 30s. The fetch is synchronous, so on a
                # cache miss that is 30s of a worker doing nothing — bound it
                # to something closer to "the frontend is briefly redeploying".
                timeout=JWKS_FETCH_TIMEOUT_SECONDS,
            )
            _jwks_client_url = url
    return _jwks_client


def verify_user(jwt_payload: dict | None, admin_only: bool) -> User:
    if jwt_payload is None:
        raise HTTPException(status_code=401, detail="Authorization header is missing")

    user_id = jwt_payload.get("sub")

    if not user_id:
        raise HTTPException(status_code=401, detail="User ID not found in token")

    if admin_only and jwt_payload.get("role") != "admin":
        raise HTTPException(status_code=403, detail="Admin access required")

    return User.from_payload(jwt_payload)

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Ensure the token payload includes the user ID (sub) claim; re-issue the token from the auth provider.
  2. Verify the token was minted by the expected issuer with the correct claims.

When it happens

Trigger: Thrown at autogpt_platform/autogpt_libs/autogpt_libs/auth/jwt_utils.py:172 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/5bb7d757e5574533. Report an issue: GitHub.