fastapi-users-db-sqlalchemy icon indicating copy to clipboard operation
fastapi-users-db-sqlalchemy copied to clipboard

fix(oauth): increase access_token and refresh_token length to 4096

Open Sohail342 opened this issue 5 months ago • 0 comments

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_token and refresh_token field 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.

Sohail342 avatar Aug 03 '25 17:08 Sohail342