> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# getBasicAuthCredentials

> Retrieve the agent's Basic Auth credentials and their origin.

Retrieve the username and password used for HTTP Basic Auth on this agent. Optionally
includes a source label indicating where the credentials came from.

## **Parameters**

**`includeSource`** `boolean` — default: false

When `true`, the returned tuple includes a third element indicating the credential
source: `"provided"` (set explicitly), `"environment"` (from `SWML_BASIC_AUTH_USER`
/ `SWML_BASIC_AUTH_PASSWORD` environment variables), or `"generated"`
(generated at startup).

---

## **Returns**

`[string, string]` -- `[username, password]` when `includeSource` is `false`.

`[string, string, string]` -- `[username, password, source]` when `includeSource` is
`true`.

## **Examples**

### Log credentials at startup

```typescript {5}
import { AgentBase } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
agent.setPromptText('You are a helpful assistant.');
const [user, password] = agent.getBasicAuthCredentials();
console.log(`Auth: ${user}:${password}`);
await agent.serve();
```

### Check credential source

```typescript {5}
import { AgentBase } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
agent.setPromptText('You are a helpful assistant.');
const [user, password, source] = agent.getBasicAuthCredentials(true);
if (source === 'generated') {
  console.log(`Auto-generated credentials: ${user}:${password}`);
  console.log('Set SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD to use your own.');
}
await agent.serve();
```