Skip to content

OauthbearerProviderResponse

reference
1 min readUpdated

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

PropertyType
valuestring

Diagram

mermaid
graph LR
  Provider[OAuth Bearer Token Provider] --> Response[OauthbearerProviderResponse]
  Response --> Token[value: string]
  Token --> KafkaClient[Kafka Client Authentication]
  KafkaClient --> Broker[Kafka Broker]

Usage

ts
import 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 value property 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 value field, 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?

Download as PDF
OauthbearerProviderResponse — NestJS head-to-head