Reputation: 1456
I have an Asp.Net core project hosting an angular application within it. There are a couple of API controllers in the asp.net core project. These controllers are called from within the Angular App.
The asp.net core app is protected by Azure AD authentication using OpenIdConnect along with Cookies. What I am looking at is how should I handle the token expiry for an overnight idle session for the user.
Currently, if a user will resume his browser session which is expired, he is thrown an exception on the async API call made from the Angular App. How should I make Angular App re-direct user back to the login page for the Azure AD application?.
Upvotes: 1
Views: 1687
Reputation: 1456
I resolved the token expiry issue by moving the token cache to Sql Server. With this done, if current in-memory token is expired, the refresh token from sql server is used to generate a new access token.
Upvotes: 2
Reputation: 783
You can implement a hidden iframe in your web app that makes a request against your server every 45 minutes or so. That way, your token will always be valid while your application is running.
This blog post talks about this issue and explain your options, including showing a script that makes the request on a scheduled interval.
Upvotes: 1