Class ClientCredentialsTokenSource

java.lang.Object
com.revetsec.oauth.ClientCredentialsTokenSource

A bounded caller-thread cache for confidential client-credentials access tokens. One caller renews; callers may continue using a valid cached token during early renewal, while callers without one share the renewal result. A rejected cached token is cleared only when invalidate(AccessToken) receives that exact instance. No expired or rejected token is returned.
Since:
1.0.0
Author:
Mark Allen
  • Method Details

    • withClient

      Starts a source using the client's configured token endpoint and deadline.
      Parameters:
      client - a confidential OAuth client
      Returns:
      the builder
      Since:
      1.0.0
    • getAccessTokenResult

      Gets a valid access token or a fixed endpoint client rejection, renewing in the calling thread when needed. An early renewal rejection or failure may serve the still-valid previous token, except after invalidation. Without a usable token, non-transient endpoint client rejections remain result values through shared renewal and backoff. Infrastructure failures remain exceptions.
      Returns:
      the acquisition outcome
      Since:
      1.0.0
    • invalidate

      public void invalidate(@NonNull AccessToken rejectedToken)
      Clears a rejected cached instance. An old 401 cannot evict a replacement token.
      Parameters:
      rejectedToken - the exact instance rejected by a resource server
      Since:
      1.0.0