Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Get token expiration date #7573


User avatar
0
antonis created

Hi,

How do I get Token expiration date?


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team
    • What is your product version?
    • What is your product type (Angular or MVC)?
    • What is product framework type (.net framework or .net core)?

    Are you using JWT or Identity server?

  • User Avatar
    0
    antonis created

    6.5 angular .net core. I m using default authentication. I suppose is JWT isn't it?

  • User Avatar
    0
    maliming created
    Support Team

    You can get the jwt token from the HttpContext via IHttpContextAccessor and parse it.

    var jwt = "(the JTW here)";
    var handler = new JwtSecurityTokenHandler();
    var token = handler.ReadJwtToken(jwt);
    
    // now do something with token.Claims, token.Audiences, etc.
    

    https://stackoverflow.com/questions/38340078/how-to-decode-jwt-token https://developer.okta.com/blog/2019/06/26/decode-jwt-in-csharp-for-authorization