Class OAuth2ClientCredentialsTokenProvider

java.lang.Object
io.openlineage.client.transports.TokenEndpointTokenProvider
io.openlineage.client.transports.OAuth2ClientCredentialsTokenProvider
All Implemented Interfaces:
TokenProvider

public class OAuth2ClientCredentialsTokenProvider extends TokenEndpointTokenProvider
TokenProvider that obtains an access token with the OAuth 2.0 client credentials grant (RFC 6749, section 4.4).

The client credentials are sent in the Authorization header ( client_secret_basic, the default) or in the request body (client_secret_post). The access token is cached and fetched again before it expires, as the client credentials grant does not issue refresh tokens.

Configuration example:


 transport:
   type: http
   url: https://api.example.com
   auth:
     type: oauth2
     clientId: your-client-id
     clientSecret: your-client-secret
     tokenEndpoint: https://auth.example.com/token
     scope: openid  # optional
     clientAuthMethod: client_secret_basic  # optional, or client_secret_post
     tokenRefreshBuffer: 120  # optional, defaults to 120 seconds
 
  • Field Details

  • Constructor Details

    • OAuth2ClientCredentialsTokenProvider

      public OAuth2ClientCredentialsTokenProvider(String clientId, String clientSecret, URI tokenEndpoint)
      Constructor that requires mandatory parameters clientId, clientSecret and tokenEndpoint. Used by Jackson for deserialization.
      Parameters:
      clientId - The OAuth 2.0 client ID (required)
      clientSecret - The OAuth 2.0 client secret (required)
      tokenEndpoint - The token endpoint URI (required)
      Throws:
      IllegalArgumentException - if clientId or clientSecret is null/empty or tokenEndpoint is null
  • Method Details

    • setClientAuthMethod

      public void setClientAuthMethod(String clientAuthMethod)
    • getTokenName

      protected String getTokenName()
      Description copied from class: TokenEndpointTokenProvider
      Name of the token used in log and error messages, for example "JWT token".
      Specified by:
      getTokenName in class TokenEndpointTokenProvider
    • getTokenRequestParameters

      protected List<org.apache.hc.core5.http.NameValuePair> getTokenRequestParameters()
      Description copied from class: TokenEndpointTokenProvider
      URL-encoded form parameters sent to the token endpoint.
      Specified by:
      getTokenRequestParameters in class TokenEndpointTokenProvider
    • getTokenRequestAuthorization

      @Nullable protected String getTokenRequestAuthorization()
      Description copied from class: TokenEndpointTokenProvider
      Value of the Authorization header sent to the token endpoint, or null for none.
      Overrides:
      getTokenRequestAuthorization in class TokenEndpointTokenProvider
    • toString

      public String toString()
      Overrides:
      toString in class TokenEndpointTokenProvider
    • getClientId

      public String getClientId()
    • getClientSecret

      public String getClientSecret()
    • getScope

      public String getScope()
      Space separated OAuth 2.0 scopes to request. Optional.
    • setScope

      public void setScope(String scope)
      Space separated OAuth 2.0 scopes to request. Optional.
    • getClientAuthMethod

      public String getClientAuthMethod()
      How the client credentials are sent to the token endpoint: "client_secret_basic" (HTTP basic Authorization header) or "client_secret_post" (request body). Optional, default: "client_secret_basic".