Wraps a TokenProvider to cache the tokens it returns. By default,
the cache will refresh tokens asynchronously a few minutes before they
expire.
The token cache is safe for concurrent use by multiple callers and will
guarantee that only one token refresh is triggered at a time.
The token cache does not take care of retries in case the token source
throws an error; it is the responsibility of the provided token source to
handle retries appropriately.
If the TokenProvider is already a cached token source (obtained by calling
this function), it is returned as is.
Wraps a TokenProvider to cache the tokens it returns. By default, the cache will refresh tokens asynchronously a few minutes before they expire.
The token cache is safe for concurrent use by multiple callers and will guarantee that only one token refresh is triggered at a time.
The token cache does not take care of retries in case the token source throws an error; it is the responsibility of the provided token source to handle retries appropriately.
If the TokenProvider is already a cached token source (obtained by calling this function), it is returned as is.