{"record":{"id":"6c2c77b157a8ea96","repo":"xtekky/gpt4free","slug":"incorrect-username-or-password","errorCode":null,"errorMessage":"Incorrect username or password","messagePattern":"Incorrect username or password","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"g4f/api/__init__.py","lineNumber":547,"sourceCode":"\nclass Api:\n    def __init__(self, app: FastAPI) -> None:\n        self.app = app\n        self.client = AsyncClient()\n        self.get_g4f_api_key = APIKeyHeader(name=\"g4f-api-key\")\n        self.conversations: dict[str, dict[str, BaseConversation]] = {}\n\n    security = HTTPBearer(auto_error=False)\n    basic_security = HTTPBasic()\n\n    async def get_username(self, request: Request) -> str:\n        credentials = await self.basic_security(request)\n        current_password_bytes = credentials.password.encode()\n        is_correct_password = secrets.compare_digest(\n            current_password_bytes, AppConfig.g4f_api_key.encode()\n        )\n        if not is_correct_password:\n            raise HTTPException(\n                status_code=HTTP_401_UNAUTHORIZED,\n                detail=\"Incorrect username or password\",\n                headers={\"WWW-Authenticate\": \"Basic\"},\n            )\n        return credentials.username\n\n    def register_authorization(self):\n        if AppConfig.g4f_api_key:\n            print(\n                \"Register authentication key:\",\n                \"\".join([\"*\" for _ in range(len(AppConfig.g4f_api_key))]),\n            )\n        if has_crypto:\n            private_key, _ = create_or_read_keys()\n            session_key = get_session_key()\n\n        def _requires_api_key(path: str, demo: bool) -> bool:\n            \"\"\"Return ``True`` when *path* must present a G4F API key.\"\"\"","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/api/__init__.py#L529-L565","documentation":"Error \"Incorrect username or password\" thrown in xtekky/gpt4free.","triggerScenarios":"Thrown at g4f/api/__init__.py:547 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the username and password configured for the API server.","Re-run authentication with valid credentials."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}