Rakesh Kumar
Rakesh Kumar

Reputation: 3129

What is the expiry date time of the access token?

When we implement the Client Credentials grant - Protecting an API using Client Credentials how long is the access token usable for (e.g. whats is the expiry date) before the client needs to generate a new access token?

Upvotes: 0

Views: 793

Answers (2)

Ryan Dobbs
Ryan Dobbs

Reputation: 381

FYI, The expiry of a JWT will be represented as Unix epoch.

For instance

{
  "exp":1517988642,
   ...
}

which can be checked in a tool such as https://www.epochconverter.com/

Upvotes: 0

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116918

When you create a client you can define the lifetime of an access token

   var myClient =  new Client
    {
    ClientId = "testClient",
    AllowedGrantTypes = GrantTypes.ClientCredentials,
    ClientSecrets =
        {
        new Secret("secret".Sha256())
        },
        AllowedScopes = { "api1" },
        AccessTokenLifetime=3600
};

If you do not supply AccessTokenLifetime then it will default to 3600 which is an hour. This means it will expire one hour after it is created

Upvotes: 4

Related Questions