- AuthJS
- Okta Classic Engine
When a token expires, the need for token renewal arises. If configured correctly, AuthJS auto-renews the expired token to maintain a smooth application flow.
Token auto-renewal in AuthJS is enabled by setting the autoRenew property to true in the AuthJS configuration. This action instructs the TokenManager to renew the expired token silently and fetch a valid token each time a request is made.
Example of AuthJS configuration:
var config = {
url: 'https://{OktaDomainName}',
tokenManager: {
storage: 'sessionStorage',
autoRenew: true
}
};
var authClient = new OktaAuth(config);
When the token has expired, and a request is made to get the tokens (via TokenManager.get), AuthJS renews the expired token without prompting the user and retrieves a valid token.
NOTE: AuthJS previously featured an auto-refresh capability for tokens, but it was removed due to a potential race condition issue. In these instances, an expired token could be fetched if a refresh and token request occurred simultaneously.
