In my app, I make a call to getSession if the user refreshes the page or tries to access a client side rout that requires the user to be authenticated.
The problem I am seeing is that the refreshToken never expires.
So I do this:
const currentSession = await authorisationProvider.getSession();
this.setState({ isAuthenticated: currentSession && currentSession.isValid(), busy: false });
But having stepped through the code and if the cachedSession.isValid() call returns false then a call is made to refreshToken which always appears to return new tokens no matter how long I leave it.
Does the refreshToken never expire or can I configure it to expire in an hour or so?
The only way for things to expire is for localStorage.clear() to be called which is obviously not a real solution.
By default, the refresh token expires 30 days after the user authenticates. When you create an app for your user pool, you can set the app's Refresh token expiration (days) to any value between 1 and 3650.
Please feel free to repoen if @tipsfedora solution doesn't work for you.
I know this issue is closed but I figured it would be useful to answer this question in the context of the original question here.
How do you set the refreshToken expiration period? I have not seen how to do this in the documentation or in the AWS Management consoles for either Cognito or my MobileHub app.
If it needs to be done in code is there an example available?
Thanks
Never mind, found it under App Clients in the Cognito management console
@tipsfedora what happend if we set the refresh token to 4 days for example, are we supposed to manage the expiration event or wtvr, for instance after 4 days the users will be disconnected or it's done automatically by amplify, so the user will be always connected ?
Most helpful comment
Never mind, found it under App Clients in the Cognito management console