---
title: "otelcol.auth.basic | Grafana Agent documentation"
description: "Learn about otelcol.auth.basic"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# otelcol.auth.basic

`otelcol.auth.basic` exposes a `handler` that can be used by other `otelcol` components to authenticate requests using basic authentication.

This extension supports both server and client authentication.

> **NOTE**: `otelcol.auth.basic` is a wrapper over the upstream OpenTelemetry Collector `basicauth` extension. Bug reports or feature requests will be redirected to the upstream repository, if necessary.

Multiple `otelcol.auth.basic` components can be specified by giving them different labels.

## Usage

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.auth.basic "LABEL" {
  username = "USERNAME"
  password = "PASSWORD"
}
```

## Arguments

`otelcol.auth.basic` supports the following arguments:

Expand table

| Name       | Type     | Description                                        | Default | Required |
|------------|----------|----------------------------------------------------|---------|----------|
| `username` | `string` | Username to use for basic authentication requests. |         | yes      |
| `password` | `secret` | Password to use for basic authentication requests. |         | yes      |

## Exported fields

The following fields are exported and can be referenced by other components:

Expand table

| Name      | Type                       | Description                                                     |
|-----------|----------------------------|-----------------------------------------------------------------|
| `handler` | `capsule(otelcol.Handler)` | A value that other components can use to authenticate requests. |

## Component health

`otelcol.auth.basic` is only reported as unhealthy if given an invalid configuration.

## Debug information

`otelcol.auth.basic` does not expose any component-specific debug information.

## Example

This example configures [otelcol.exporter.otlp](../otelcol.exporter.otlp/) to use basic authentication:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
otelcol.exporter.otlp "example" {
  client {
    endpoint = "my-otlp-grpc-server:4317"
    auth     = otelcol.auth.basic.creds.handler
  }
}

otelcol.auth.basic "creds" {
  username = "demo"
  password = env("API_KEY")
}
```
