public class CachedTokenSource extends Object implements TokenSource
This class supports both synchronous and asynchronous token refresh. When async is enabled, stale tokens will trigger a background refresh, while expired tokens will block until a new token is fetched.
| Modifier and Type | Class and Description |
|---|---|
static class |
CachedTokenSource.Builder
Builder for creating instances of
CachedTokenSource. |
| Modifier and Type | Method and Description |
|---|---|
Token |
getToken()
Gets the current token, refreshing if necessary.
|
protected Token |
getTokenAsync()
Get the current token, possibly triggering an async refresh if stale.
|
protected Token |
getTokenBlocking()
Get the current token, blocking to refresh if expired.
|
protected com.databricks.sdk.core.oauth.CachedTokenSource.TokenState |
getTokenState(Token t)
Determine the state of the current token (fresh, stale, or expired).
|
protected volatile Token token
public Token getToken()
This method may throw an exception if the token cannot be refreshed, depending on the
implementation of #refresh().
getToken in interface TokenSourceprotected com.databricks.sdk.core.oauth.CachedTokenSource.TokenState getTokenState(Token t)
protected Token getTokenBlocking()
This method may throw an exception if the token cannot be refreshed, depending on the
implementation of #refresh().
protected Token getTokenAsync()
This method may throw an exception if the token cannot be refreshed, depending on the
implementation of #refresh().
Copyright © 2026. All rights reserved.