Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Boilerplate token expiration

I'm using ASP.NET Boilerplate. I have an application in Angular (external to ABP) that I would like to consume my API.

For that, I get an access token via /api/TokenAuth/Authenticate, and then I use the token in the calls to my API.

The problem is that the token expires in 1 day and I would like the user session to persist longer, without the user having to login every 1 day.

Any idea how I can achieve that? I would like to make the token expiration time longer, even though I have read that it is insecure.

Thanks for the help!

like image 242
Leonardo Fernandez da Silva Avatar asked Sep 01 '18 19:09

Leonardo Fernandez da Silva


People also ask

How do you handle expired tokens?

So in summary when authorization is successful you need to issue two token ACCESS_TOKEN and REFRESH_TOKEN. When ACCESS_TOKEN expires you need to call another api with REFRESH_TOKEN to get new ACCESS_TOKEN. The client application can get a new access token as long as the refresh token is valid and unexpired.

How do I check my refresh token expiry?

If you look in the dashboard application settings, you can see the Refresh Token expiration time. By default, it is 720 hours (2592000 seconds). Since the error message says inavlid_grant , it may be possible that the application is not configured to accept Refresh Token grants.


1 Answers

You can modify tokenAuthConfig.Expiration in YourProjectNameWebCoreModule.

private void ConfigureTokenAuth()
{
    // ...

    tokenAuthConfig.Expiration = TimeSpan.FromDays(1);
}
like image 189
aaron Avatar answered Sep 18 '22 22:09

aaron