I create a token with IdentityServer4 I copy this example I just modify this
in IdentityServer -> Config
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "client",
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowedScopes = { "tbtsmth" },
AccessTokenLifetime = 10,
IdentityTokenLifetime = 10
}
};
}
My token should expired in 10 seconds and every 10 seconds I have a refresh token, but I don't know how to test it. I do something like that :
var tokenHandler = new JwtSecurityTokenHandler();
var jwtSecurityToken = tokenHandler.ReadJwtToken(tokenResponse.AccessToken);
Thread.Sleep(10000);
if (jwtSecurityToken.ValidTo < DateTime.UtcNow)
Console.WriteLine("expired");
else
Console.WriteLine("not expired");
it returns me expired I thought that it should return me not expired because it will be refreshed.