{"record":{"id":"3191b0ec39fecc36","repo":"nicolargo/glances","slug":"password-authentication-is-not-enabled-start-glan","errorCode":null,"errorMessage":"Password authentication is not enabled. Start Glances with --password option.","messagePattern":"Password authentication is not enabled\\. Start Glances with --password option\\.","errorType":"http","errorClass":"HTTPException","httpStatus":501,"severity":"error","filePath":"glances/outputs/glances_restful_api.py","lineNumber":818,"sourceCode":"        }\n\n        Returns:\n        {\n            \"access_token\": \"string\",\n            \"token_type\": \"bearer\",\n            \"expires_in\": int (seconds)\n        }\n        \"\"\"\n        # Check if JWT is available\n        if self._jwt_handler is None or not self._jwt_handler.is_available:\n            raise HTTPException(\n                status.HTTP_501_NOT_IMPLEMENTED,\n                \"JWT authentication is not available. Install python-jose or check configuration.\",\n            )\n\n        # Check if password authentication is enabled\n        if self._password is None:\n            raise HTTPException(\n                status.HTTP_501_NOT_IMPLEMENTED,\n                \"Password authentication is not enabled. Start Glances with --password option.\",\n            )\n\n        # Parse request body\n        try:\n            body = await request.json()\n        except Exception:\n            raise HTTPException(status.HTTP_400_BAD_REQUEST, \"Invalid JSON body\")\n\n        username = body.get('username')\n        password = body.get('password')\n\n        if not username or not password:\n            raise HTTPException(\n                status.HTTP_400_BAD_REQUEST,\n                \"Missing username or password in request body\",\n            )","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_restful_api.py#L800-L836","documentation":"/api/4/token requires the server to run with password mode enabled (self._password set, i.e. glances started with --password). Without it there are no credentials to validate the token request against, so the endpoint returns 501 telling you to restart with --password.","triggerScenarios":"Starting glances -w (no --password, anonymous mode) and POSTing to /api/4/token; token-based auth is meaningless because all endpoints are already open.","commonSituations":"Users experimenting with the token endpoint on default unauthenticated instances; switching a deployment to password mode but forgetting to add the flag.","solutions":["Restart Glances with --password (glances -w --password) and set the password when prompted.","If you actually want anonymous access, skip the token endpoint entirely — the API is already open."],"exampleFix":"# before\nglaces -w\ncurl -X POST http://localhost:61208/api/4/token\n# 501 Password authentication is not enabled\n\n# after\nglaces -w --password\ncurl -X POST http://localhost:61208/api/4/token -d '{\"username\":\"u\",\"password\":\"p\"}'","handlingStrategy":"validation","validationCode":"r = requests.get(f'{base}/api/4/config')\nif r.status_code == 200:\n    pass  # anonymous mode: token endpoint not needed\nelse:\n    # authenticated mode: token flow available","typeGuard":null,"tryCatchPattern":"r = requests.post(f'{base}/api/4/token', json=creds)\nif r.status_code == 501 and 'password' in r.text:\n    # server started without --password; use anonymous access instead","preventionTips":["Start with --password when token auth is desired.","Don't call /api/4/token against unauthenticated instances."],"tags":["authentication","http-501","configuration","rest-api"],"backgroundTag":"endpoint-requires-auth-config","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}