Customizing Token Management
Implement and provide a custom TokenStore class for token get, set and clear operations.
Default Functionality
By default, PassageJS and the Passage Elements will store, lookup and clear auth tokens in both localstorage and in a cookie using a consistent key value.
Creating a Custom Token Store
If you'd like to handle client-side auth token storage differently than the built-in default, you can pass your own TokenStore as a config option for either PassageJS or the Passage elements.
Store and retrieve your tokens in the method best for your use case
Perform custom logic or call an API before you set or remove a token
TokenStore Detail
All class methods should return a promise.
Required Methods
getAuthToken
Returns a promise containing the auth token value for PassageJS to use for authorized API calls.
setTokens
Given an auth response on login completion you have the ability to set your token(s) via any storage mechanism (asynchronous or synchronous). It should return a promise.
Optional Methods
clearTokens
This method is called when you use the Session .signout()
method. It should clear your targeted tokens and return a promise.
getRefreshToken
Returns a promise containing the refresh token value for PassageJS to use. This will be used silently behind the scenes when making authenticated requests. See Refresh Tokens for more details.
Last updated