Class TokenEndpointTokenProvider

java.lang.Object
io.openlineage.client.transports.TokenEndpointTokenProvider
All Implemented Interfaces:
TokenProvider
Direct Known Subclasses:
JwtTokenProvider, OAuth2ClientCredentialsTokenProvider

public abstract class TokenEndpointTokenProvider extends Object implements TokenProvider
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 Details

    • TokenEndpointTokenProvider

      protected TokenEndpointTokenProvider(URI tokenEndpoint, String... defaultTokenFields)
      Parameters:
      tokenEndpoint - The token endpoint URI, validated by the subclass constructor together with its other required parameters
      defaultTokenFields - JSON field names to search for the token unless tokenFields is configured
  • Method Details

    • getTokenName

      protected abstract String getTokenName()
      Name of the token used in log and error messages, for example "JWT token".
    • getTokenRequestParameters

      protected abstract List<org.apache.hc.core5.http.NameValuePair> getTokenRequestParameters()
      URL-encoded form parameters sent to the token endpoint.
    • getTokenRequestAuthorization

      @Nullable protected String getTokenRequestAuthorization()
      Value of the Authorization header sent to the token endpoint, or null for none.
    • getToken

      public String getToken()
      Specified by:
      getToken in interface TokenProvider
    • 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

      public String toString()
      Overrides:
      toString in class Object
    • getTokenEndpoint

      public URI getTokenEndpoint()
    • getTokenFields

      public String[] getTokenFields()
      The JSON field names to search for the token in the response, tried in order.
    • setTokenFields

      public void setTokenFields(String[] tokenFields)
      The JSON field names to search for the token in the response, tried in order.
    • getExpiresInField

      public String 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

      public void setExpiresInField(String expiresInField)
      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.