Skip to content

tokenSource

function tokenSource<C>(options): TokenSource<C>;

Defined in: core/src/auth/token-source.ts:40

Refresh when the stored credential has expired or was rejected, and only then.

  • Concurrent calls share one refresh and the result is saved before use.
  • When the server rejects the refresh, the stored credential is reloaded. If another context saved a newer one meanwhile, that one is used. Otherwise the session is dead and the error says so.
  • A network failure keeps the credential and rethrows, so a user on bad wifi isn’t told to sign in again.

ponytail: two contexts can both lose a refresh before either one saves, and then both fail. Closing that needs a lock on the storage.

Type Parameter
C extends Credential
Parameter Type
options TokenSourceOptions<C>

TokenSource<C>