{
  "id": "python/fastapi-oauth2-password-error",
  "signature": "fastapi.security.OAuth2PasswordRequestForm: 400 Bad Request: Incorrect username or password",
  "signature_zh": "FastAPI安全：400错误请求：用户名或密码不正确",
  "regex": "fastapi\\.security\\.OAuth2PasswordRequestForm:\\ 400\\ Bad\\ Request:\\ Incorrect\\ username\\ or\\ password",
  "domain": "python",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The OAuth2 password flow receives invalid credentials, either because the user doesn't exist or the password hash doesn't match.",
  "root_cause_type": "generic",
  "root_cause_zh": "OAuth2密码流程收到无效凭据，可能是因为用户不存在或密码哈希不匹配。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Storing plaintext passwords and comparing directly is insecure and may cause hash mismatches.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using the wrong hashing algorithm (e.g., md5) can cause verification failures.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use passlib and bcrypt: from passlib.context import CryptContext\\npwd_context = CryptContext(schemes=['bcrypt'], deprecated='auto')\\nif not pwd_context.verify(password, user.hashed_password):\\n    raise HTTPException(400)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Check if the user exists first: user = db.query(User).filter(User.username == username).first()\\nif not user:\\n    raise HTTPException(400)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}