Kind: Interface
Source: packages/microservices/external/kafka.interface.ts
Part of: Microservices
OauthbearerProviderResponse defines the response returned by an OAuth bearer token provider for Kafka authentication. It contains the bearer token value that Kafka clients use when establishing authenticated connections to a broker.
Properties
| Property | Type |
|---|---|
value | string |
Diagram
mermaidgraph LR Provider[OAuth Bearer Token Provider] --> Response[OauthbearerProviderResponse] Response --> Token[value: string] Token --> KafkaClient[Kafka Client Authentication] KafkaClient --> Broker[Kafka Broker]
Usage
tsimport type { OauthbearerProviderResponse } from './kafka.interface';
async function getKafkaOAuthToken(): Promise<OauthbearerProviderResponse> {
const accessToken = await fetchAccessTokenFromIdentityProvider();
return {
value: accessToken,
};
}
async function fetchAccessTokenFromIdentityProvider(): Promise<string> {
// Replace with your identity provider integration.
return process.env.KAFKA_OAUTH_TOKEN ?? '';
}
AI Coding Instructions
- Return an object with a
valueproperty containing the OAuth bearer token string. - Keep token acquisition logic separate from the response shape; this interface only represents the provider result.
- Avoid logging the
valuefield, as it contains sensitive authentication credentials. - Ensure the token is valid and refreshed before Kafka clients request authentication.
- Integrate the provider with the Kafka client configuration expected by the microservices package.
Was this page helpful?