JWT with no expires date

253 Views Asked by At

I'm using Microsoft.IdentityModel.Tokens to create a JWT but I need a token with no expiration date, can I create that token with the CreateJwtSecurityToken function? I tried ignoring the expires parameter but that not work.

1

There are 1 best solutions below

0
Tore Nestenius On

An alternative is to have the ASP.NET WEB.API to ignore the expire dates of the token using this property:

TokenValidationParameters.ValidateLifetime

You set it inside AddJwtBearer(...);

To complement this answer, I wrote a blog post that goes into more detail about this topic: Troubleshooting JwtBearer authentication problems in ASP.NET Core