Package com.databricks.sdk.core.oauth
Class RefreshableTokenSource
- java.lang.Object
-
- com.databricks.sdk.core.oauth.RefreshableTokenSource
-
- All Implemented Interfaces:
TokenSource
- Direct Known Subclasses:
ClientCredentials
,CliTokenSource
,SessionCredentials
public abstract class RefreshableTokenSource extends Object implements TokenSource
An OAuth TokenSource which can be refreshed.Calls to getToken() will first check if the token is still valid (currently defined by having at least 10 seconds until expiry). If not, refresh() is called first to refresh the token.
-
-
Constructor Summary
Constructors Constructor Description RefreshableTokenSource()
RefreshableTokenSource(Token token)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Token
getToken()
protected abstract Token
refresh()
protected static Token
retrieveToken(HttpClient hc, String clientId, String clientSecret, String tokenUrl, Map<String,String> params, Map<String,String> headers, AuthParameterPosition position)
Helper method implementing OAuth token refresh.
-
-
-
Field Detail
-
token
protected Token token
-
-
Constructor Detail
-
RefreshableTokenSource
public RefreshableTokenSource()
-
RefreshableTokenSource
public RefreshableTokenSource(Token token)
-
-
Method Detail
-
retrieveToken
protected static Token retrieveToken(HttpClient hc, String clientId, String clientSecret, String tokenUrl, Map<String,String> params, Map<String,String> headers, AuthParameterPosition position)
Helper method implementing OAuth token refresh.- Parameters:
clientId
- The client ID to authenticate with.clientSecret
- The client secret to authenticate with.tokenUrl
- The authorization URL for fetching tokens.params
- Additional request parameters.headers
- Additional headers.position
- The position of the authentication parameters in the request.- Returns:
- The newly fetched Token.
-
refresh
protected abstract Token refresh()
-
getToken
public Token getToken()
- Specified by:
getToken
in interfaceTokenSource
-
-