Package io.openlineage.client.transports
Class TokenEndpointTokenProvider
java.lang.Object
io.openlineage.client.transports.TokenEndpointTokenProvider
- All Implemented Interfaces:
TokenProvider
- Direct Known Subclasses:
JwtTokenProvider,OAuth2ClientCredentialsTokenProvider
Base class for TokenProviders that obtain a short-lived bearer token from a token endpoint.
The token is cached and fetched again tokenRefreshBuffer seconds before it expires.
Subclasses provide the URL-encoded form parameters of the token request and, optionally, the
Authorization header sent to the token endpoint.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTokenEndpointTokenProvider(URI tokenEndpoint, String... defaultTokenFields) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.hc.client5.http.impl.classic.CloseableHttpClientCreates an HTTP client for token requests.protected longGets current time in epoch seconds.The JSON field name containing the token expiration time in seconds.getToken()String[]The JSON field names to search for the token in the response, tried in order.protected abstract StringName of the token used in log and error messages, for example "JWT token".intNumber of seconds before token expiry to trigger a refresh.protected StringValue of theAuthorizationheader sent to the token endpoint, or null for none.protected abstract List<org.apache.hc.core5.http.NameValuePair>URL-encoded form parameters sent to the token endpoint.voidsetExpiresInField(String expiresInField) The JSON field name containing the token expiration time in seconds.voidsetTokenFields(String[] tokenFields) The JSON field names to search for the token in the response, tried in order.voidsetTokenRefreshBuffer(int tokenRefreshBuffer) Number of seconds before token expiry to trigger a refresh.toString()
-
Constructor Details
-
TokenEndpointTokenProvider
- Parameters:
tokenEndpoint- The token endpoint URI, validated by the subclass constructor together with its other required parametersdefaultTokenFields- JSON field names to search for the token unlesstokenFieldsis configured
-
-
Method Details
-
getTokenName
Name of the token used in log and error messages, for example "JWT token". -
getTokenRequestParameters
URL-encoded form parameters sent to the token endpoint. -
getTokenRequestAuthorization
Value of theAuthorizationheader sent to the token endpoint, or null for none. -
getToken
- Specified by:
getTokenin interfaceTokenProvider
-
getCurrentTimeSeconds
protected long getCurrentTimeSeconds()Gets current time in epoch seconds. Protected to allow test overrides. -
createHttpClient
protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient createHttpClient()Creates an HTTP client for token requests. Protected to allow test overrides. -
toString
-
getTokenEndpoint
-
getTokenFields
The JSON field names to search for the token in the response, tried in order. -
setTokenFields
The JSON field names to search for the token in the response, tried in order. -
getExpiresInField
The JSON field name containing the token expiration time in seconds. Defaults to "expires_in". If not present in response, token will be refreshed on every call. -
setExpiresInField
The JSON field name containing the token expiration time in seconds. Defaults to "expires_in". If not present in response, token will be refreshed on every call. -
getTokenRefreshBuffer
public int getTokenRefreshBuffer()Number of seconds before token expiry to trigger a refresh. Optional, default: 120 seconds. This buffer ensures tokens are refreshed before they expire to avoid authentication failures. -
setTokenRefreshBuffer
public void setTokenRefreshBuffer(int tokenRefreshBuffer) Number of seconds before token expiry to trigger a refresh. Optional, default: 120 seconds. This buffer ensures tokens are refreshed before they expire to avoid authentication failures.
-