Significant-Gravitas/AutoGPT · error · ValueError
Invalid token: {str(e)}
Error message
Invalid token: {str(e)} What it means
Error "Invalid token: {str(e)}" thrown in Significant-Gravitas/AutoGPT.
Source
Thrown at autogpt_platform/autogpt_libs/autogpt_libs/auth/jwt_utils.py:98
Symmetric (HS*) tokens are verified with the shared secret
(`JWT_VERIFY_KEY`); asymmetric tokens are verified against the JWK set
published by the platform auth service (`JWT_JWKS_URL`). Both paths can be
active at once, which keeps sessions issued by a previous auth provider
valid during a migration window.
:param token: The token to parse
:param audience: The `aud` claim the token must carry. Defaults to the
user-token audience; service tokens use a distinct audience so the
two planes can't be replayed against each other.
:return: The decoded payload
:raises ValueError: If the token is invalid or expired
"""
settings = get_settings()
try:
header = jwt.get_unverified_header(token)
except jwt.InvalidTokenError as e:
raise ValueError(f"Invalid token: {str(e)}") from e
algorithm = header.get("alg", "")
if algorithm.startswith("HS"):
if not settings.JWT_VERIFY_KEY:
raise ValueError("Invalid token: symmetric tokens are not accepted")
key = settings.JWT_VERIFY_KEY
algorithms = [settings.JWT_ALGORITHM]
else:
if not settings.JWT_JWKS_URL:
raise ValueError("Invalid token: asymmetric tokens are not accepted")
try:
key = _get_jwks_client().get_signing_key_from_jwt(token).key
algorithms = settings.JWT_JWKS_ALGORITHMS
except jwt.PyJWKClientError as e:
# The legacy verifier supported — and its config text recommended —
# asymmetric algorithms, with the public key in JWT_VERIFY_KEY. A
# token whose kid isn't in the Better Auth JWK set can therefore
# still be a live legacy session from that configuration, so theView on GitHub (pinned to 9c8bb5550f)
Solutions
- Obtain a fresh token by signing in again; the current token is malformed or tampered with.
- Verify the token is not truncated or corrupted in transit (check proxies/header size limits).
When it happens
Trigger: Thrown at autogpt_platform/autogpt_libs/autogpt_libs/auth/jwt_utils.py:98 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/d2b90fd371963d7e.
Report an issue: GitHub.