nicolargo/glances · error · HTTPException
JWT authentication is not available. Install python-jose or
Error message
JWT authentication is not available. Install python-jose or check configuration.
What it means
The /api/4/token endpoint raises HTTP 501 when self._jwt_handler is None or its is_available is False — meaning the JWT layer (python-jose dependency and/or a usable secret) isn't present, so token issuance is impossible. This mirrors the RuntimeError from GlancesJWT.create_access_token but is surfaced as an HTTP error.
Source
Thrown at glances/outputs/glances_restful_api.py:811
Generate a JWT access token for authenticated users.
Expected JSON body:
{
"username": "string",
"password": "string"
}
Returns:
{
"access_token": "string",
"token_type": "bearer",
"expires_in": int (seconds)
}
"""
# Check if JWT is available
if self._jwt_handler is None or not self._jwt_handler.is_available:
raise HTTPException(
status.HTTP_501_NOT_IMPLEMENTED,
"JWT authentication is not available. Install python-jose or check configuration.",
)
# Check if password authentication is enabled
if self._password is None:
raise HTTPException(
status.HTTP_501_NOT_IMPLEMENTED,
"Password authentication is not enabled. Start Glances with --password option.",
)
# Parse request body
try:
body = await request.json()
except Exception:
raise HTTPException(status.HTTP_400_BAD_REQUEST, "Invalid JSON body")
username = body.get('username')View on GitHub (pinned to a240d8dfb3)
Solutions
- pip install 'glances[api]' (or pip install python-jose) on the server and restart Glances.
- Run once with --password so the JWT secret is created/persisted.
- Retry POST /api/4/token; if still 501, check glances.log for JWT init messages.
Example fix
# before
pip install glances
glaces -w --password
curl -X POST http://localhost:61208/api/4/token
# 501 JWT authentication is not available
# after
pip install 'glances[api]'
glaces -w --password
curl -X POST http://localhost:61208/api/4/token -d '{"username":"u","password":"p"}' Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec('jose') is None:
raise SystemExit("pip install 'glances[api]' to enable /api/4/token") Try / catch
r = requests.post(f'{base}/api/4/token', json=creds)
if r.status_code == 501:
raise SystemExit('server lacks JWT support — use Basic auth or install glances[api]') Prevention
- Include glances[api] in deployment requirements.
- Smoke-test /api/4/token after deployment; a 501 means missing dependency/config.
- Fall back to Basic auth when token issuance is unavailable.
When it happens
Trigger: POST /api/4/token on a Glances started with --password but without python-jose installed or without a JWT secret configured. The endpoint checks availability before parsing the body, so the 501 comes back regardless of payload.
Common situations: pip installs of bare glances without the [api] extra; Docker images missing the dependency; upgrades that dropped python-jose; fresh installs where the secret generation step never ran.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- JWT authentication is not available
- Incorrect authentication
- Password authentication is not enabled. Start Glances with -
- The 'mcp' package is required for MCP support. Install it wi
- Not authenticated
AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27).
Data as JSON: /api/errors/f8beed0934b926da.
Report an issue: GitHub.