I am looking to implement sliding token expiration with a JavaScript application using the Resource Owner Flow.
Our code is similar to the "JavaScript Resource Owner Flow" project within the IdentityServer3.Samples.Clients solution.
I would like to be able to get the token once and then continue to use that token until it expires (on a sliding expiration).
In sudo code the logic is as follows...
- if token is undefined then call getToken() and save the result to the token variable
- Use this token variable to call an api that is protected by identity server
My issue is that if the token expiration is set to 60 seconds and I call the api once every 5 seconds, on the 13 attempt the token has expired, however I would expect the token to have been refreshed.
An example of my client config is below...
{
"enabled": true,
"clientId": "myClient",
"clientSecrets": [
{
"description": null,
"value": "xxxxxxxxxxx",
"expiration": null,
"type": "SharedSecret"
}
],
"clientName": "myClient",
"clientUri": null,
"logoUri": null,
"requireConsent": true,
"allowRememberConsent": true,
"flow": "ResourceOwner",
"allowClientCredentialsOnly": false,
"redirectUris": [],
"postLogoutRedirectUris": [],
"logoutUri": null,
"logoutSessionRequired": true,
"requireSignOutPrompt": false,
"allowAccessToAllScopes": false,
"allowedScopes": [
"openid",
"email",
"address",
"offline_access",
"scopeA",
"scopeB"
],
"identityTokenLifetime": 300,
"accessTokenLifetime": 60, // TODO - token expiry is only 60 seconds for testing purposes
"authorizationCodeLifetime": 300,
"absoluteRefreshTokenLifetime": 86400,
"slidingRefreshTokenLifetime": 43200,
"refreshTokenUsage": "OneTimeOnly",
"updateAccessTokenClaimsOnRefresh": false,
"refreshTokenExpiration": "Sliding",
"accessTokenType": "Reference",
"enableLocalLogin": true,
"identityProviderRestrictions": [],
"includeJwtId": false,
"configClaims": [],
"alwaysSendClientClaims": true,
"prefixClientClaims": true,
"allowAccessToAllCustomGrantTypes": false,
"allowedCustomGrantTypes": [],
"allowedCorsOrigins": [
"http://localhost"
],
"allowAccessTokensViaBrowser": true
}