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

Increase max access and refresh token length to 4096

Open maxdorninger opened this issue 5 months ago • 0 comments

This PR updates the SQLAlchemyBaseOAuthAccountTable class to increase the maximum length of the access and refresh token fields from 1024 to 4096 chars. This is necessary because, OAuth2 providers like Authentik generate tokens with an algorithm like RS256. These the access tokens exceed the max length of 1024 chars which leads to errors like these, ultimately blocking the user from logging in.

sqlalchemy.exc.DataError: (psycopg.errors.StringDataRightTruncation) value too long for type character varying(1024)

Related issues:

  • https://github.com/fastapi-users/fastapi-users/issues/1523
  • https://github.com/fastapi-users/fastapi-users-db-sqlalchemy/issues/20

maxdorninger avatar Aug 03 '25 17:08 maxdorninger