I am using System.IdentityModel.Tokens.Jwt
package and the below code decoding the jwt
token, but it won't give exp
value?
var handler = new JwtSecurityTokenHandler();
var decodedValue = handler.ReadJwtToken("token");
How to get exp
and compare it with the current DateTime to calculate token is expired or not?
Update:
I am using Azure.Core.AccessToken
where I have the below property,
public DateTimeOffset ExpiresOn
{
get;
}
ValidTo
field isn't returning a validDateTime
representative of the expiry? If not, can you clarify your question, please? – CloraclorindaExpiresOn
coming as part of access token, how to compare this DateTimeOffset with current date? – AlexanderExpiresOn
inJwtSecurityToken
's docs (here), though it does state thatValidTo
represents theexp
claim. Where are you seeing theExpiresOn
property? – Cloraclorindaif (token.ExpiresOn > DateTimeOffset.UtcNow)
or something? – CloraclorindaAzure.Core.AccessToken
token – Alexanderif (token.ExpiresOn > DateTimeOffset.UtcNow)
. Thanks! – Alexander