The access token expired and a refresh token is not available. The user will need to sign in again. What now?

Hi @paleloser,

I would need a bit more of background information about your specific cases and how you are building and calling your API routes.

The SDK won’t redirect when you call the getAccessToken or getSession token because there are scenarios where you want to check on those without having to redirect.

If you want to cause a redirection you can either use a middleware validation, or withApiAuthRequired on each API route, no need for a try/catch, though you’ll have to add that wrapper to each API route.

Protecting an API with withApiAuthRequired will cause the API to return a 401, and you’ll have to handle the redirection on the client side.

Does this help?
Juan

1 Like