Interface Credential

All Known Implementing Classes:
ApiKeyCredential, FileCredential
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Credential
Supplies a bearer token before each Client or Worker service call.

Implementations must be safe for concurrent calls. A blocked lookup can occupy a gRPC executor thread after a deadline or cancellation ends the call. ApiKeyCredential bounds its first and expired-token exchanges by a timeout. A failure prevents the request from reaching Dex and becomes a Client DexServiceException with gRPC UNAUTHENTICATED, or an IllegalStateException during Worker startup. Pull Worker streams obtain a token when each stream opens, so reconnects pick up rotated tokens. Tokens travel over the same plaintext gRPC connection as other requests; protect the network path to Dex.

Credential credential = () -> currentToken.get();
ClientOptions options = ClientOptions.newBuilder().credential(credential).build();
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the current printable ASCII token without the Bearer prefix.
  • Method Details

    • token

      String token() throws Exception
      Returns the current printable ASCII token without the Bearer prefix.

      This method can run concurrently for different calls. Throw when no usable token is available; Dex is not contacted for that call. Spaces, control characters, and non-ASCII characters fail the call as UNAUTHENTICATED. Avoid including the token in exception messages, which may be shown to the caller.

      Returns:
      the nonempty bearer token
      Throws:
      Exception - if the token cannot be supplied