fastapi-users-db-sqlalchemy
fastapi-users-db-sqlalchemy copied to clipboard
fix(oauth): increase access_token and refresh_token length to 4096
When using OAuth2 providers such as Authentik with RS256-signed access tokens, the access_token (and sometimes refresh_token) exceeds 1024 characters. This results in a StringDataRightTruncation error in PostgreSQL:
psycopg.errors.StringDataRightTruncation: value too long for type character varying(1024)
Changes
- Increased
access_tokenandrefresh_tokenfield lengths from 1024 to 4096. - Verified behavior against PostgreSQL using long RS256 tokens.
- All tests pass with 100% coverage using
hatch run test.
Configuration
- Python: 3.13
- FastAPI: 0.115.12
- fastapi-users-db-sqlalchemy: latest main
This should allow broader compatibility with modern OAuth2 providers.