Repository navigation
Description
Is your feature request related to a problem? Please describe.
Serverpod aims to support JWT token authentication, and this requires support for access and refresh tokens, as specified by the OAuth 2.0 standard.
Refresh and access tokens should be integrated into the Serverpod client and automatically handled. The client should be able to detect when an access token is outdated and request a new one using any stored refresh token.
Describe the solution you'd like
Storage of refresh and access tokens
The authentication key manager is currently designed only to support a single authentication key. Therefore, it must be expanded to support managing an optimal refresh token.
If no refresh token is configured, the refreshing of the access token should be disabled.
Configurable refresh token request
To update an access token, a call towards a refresh token endpoint containing the refresh token needs to be made.
To support custom refresh token schemes (for example, a centralized authentication server for multiple applications), it should be possible to configure how the refresh token request looks and where it is sent.
This should configured directly in the client.
If no refresh token request is configured, the refreshing of access tokens should be disabled.
Automatic renewal of access token
The following preconditions need to be satisfied to enable the automatic renewal of an access token:
- A refresh token is stored.
- A refresh token endpoint is configured.
If a request to an authenticated endpoint responds with a 401 HTTP status code, the automatic renewal of the access token should be triggered and the old access token should be discarded.
When triggered, a call is made to the configured refresh token endpoint containing the refresh token. If an access token is returned, it should be stored for future use.
If the server rejects the refresh token, it should be discarded.
Automatic call retry when the access token is updated
If an access token renewal succeeds, the client should automatically retry the call to the authenticated endpoint.
Describe alternatives you've considered
Additional context
With the Serverpod authentication module, no additional configuration should be required to get authentication working. That is, reasonable defaults that work with the authentication module should exist.
Special consideration should be taken to how discarding access and refresh tokens influence the logged-in state of the application.
Related issues:
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone 🚀
Activity
marcelomendoncasoares commentedon Mar 26, 2026
Closing since this was done during the implementation of JWT support for Serverpod 3.0 new auth.