# OauthbearerProviderResponse

**Kind:** Interface

**Source:** [`packages/microservices/external/kafka.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/microservices/external/kafka.interface.ts#L85)

**Part of:** [Microservices](subsystem-packages-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

```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.
