# Interface TokenStore

All Known Implementing Classes:
  `TokenStore.DefaultStorageTokenStore`

public interface TokenStore

Pluggable persistence for an `OidcClient`'s tokens. Implement this and pass to `OidcClient.setTokenStore(TokenStore)` when you want a custom strategy (e.g. cross-device sync, encrypted-at-rest with your own key, in-memory only). The default is `TokenStore.DefaultStorageTokenStore`, which serialises tokens to the standard `Storage` under a per-issuer key. For biometric-gated persistence on iOS / Android, use

invalid reference

    SecureStorageTokenStore

.

All methods are asynchronous and may run network or biometric prompts on the calling thread.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static final class`
  `TokenStore.DefaultStorageTokenStore`
  The default store.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AsyncResource<Boolean>`
  `clear(String key)`
  Removes the entry for `key`.
  `AsyncResource<OidcTokens>`
  `load(String key)`
  Reads previously-saved tokens for `key`, or completes with `null` if nothing is stored.
  `AsyncResource<Boolean>`
  `save(String key, OidcTokens tokens)`
  Persists `tokens` under `key`.

- ## Method Details

  - ### load

    AsyncResource<OidcTokens> load(String key)
    Reads previously-saved tokens for `key`, or completes with `null` if nothing is stored.

  - ### save

    AsyncResource<Boolean> save(String key, OidcTokens tokens)
    Persists `tokens` under `key`. Implementations should overwrite any existing entry atomically.

  - ### clear

    AsyncResource<Boolean> clear(String key)
    Removes the entry for `key`. Completing with `Boolean.FALSE` means nothing was stored; completing with an error means the underlying store failed.