Publish Python 3.13 FastAPI JWT Bcrypt Fix Guide
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142---license: mittags: - fastapi - python-3.13 - bcrypt - passlib - jwt-authentication---
# 🛡️ Fixing `ValueError: password cannot be longer than 72 bytes` in Python 3.12 / 3.13 (`passlib` + `bcrypt`)
[](https://yahiaoui26.gumroad.com/l/fastapi-gemini-blueprint)[](https://yahiaoui26.gumroad.com/l/shipai-pro/BLUEPRINT30)
When deploying **FastAPI** authentication routes using `passlib[bcrypt]` on **Python 3.12 or Python 3.13**, newer versions of `bcrypt` (`>= 4.1.0`) raise:```textValueError: password cannot be longer than 72 bytes, truncate manually if necessary```during `passlib`'s internal `detect_wrap_bug` startup check.
## ✅ The Instant Production Fix
Pin `bcrypt==4.0.1` alongside `passlib[bcrypt]` in your `requirements.txt`:
```txtfastapiuvicornpasslib[bcrypt]bcrypt==4.0.1python-jose[cryptography]pydantic[email]```
---
## 🎁 Building a FastAPI + AI Micro-SaaS in 2026?
Don't waste 30+ hours debugging Python 3.13 auth, JWT bearer guards, SaaS user credit quotas, and Google Gemini structured JSON outputs from scratch:
* 📘 **[Download the Free 2026 FastAPI + Gemini Architecture Blueprint ($0)](https://yahiaoui26.gumroad.com/l/fastapi-gemini-blueprint)*** 🚀 **[Get ShipAI v2.0 Commercial Micro-SaaS Boilerplate (30% OFF with code `BLUEPRINT30`)](https://yahiaoui26.gumroad.com/l/shipai-pro/BLUEPRINT30)**README.mdAdded+42