-
Notifications
You must be signed in to change notification settings - Fork 8
Client credentials caching
Andrea Di Lisio edited this page Aug 29, 2023
·
5 revisions
The library comes with options for caching client credentials, thus avoiding to call Oauth endpoints on each authenticated API invocation.
By default, the library does not cache any token. To enable the caching feature there are two options: using a default in-memory cache or define custom cache storage. Either way developers are not asked to provide an implementation that takes care of the expiration of the token.
To enable the default in memory cache it's enough to invoke the withCredentialsCaching()
on the client builder instance.
TrueLayerClientBuilder sut = new TrueLayerClientBuilder()
.clientCredentials(getClientCredentials())
.signingOptions(getSigningOptions())
.withHttpLogs()
.withCredentialsCaching();
To define a custom cache storage you can provide an implementation of the ICredentialsCache interface:
TrueLayerClientBuilder sut = new TrueLayerClientBuilder()
.clientCredentials(getClientCredentials())
.signingOptions(getSigningOptions())
.withHttpLogs()
.withCredentialsCaching(MyCustomCacheImpl);
You need to provide a custom cache implementation of the ICredentialsCache interface.