***

title: getBasicAuthCredentials
slug: /reference/typescript/agents/agent-base/get-basic-auth-credentials
description: Retrieve the agent's Basic Auth credentials and their origin.
max-toc-depth: 3
---------------------

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

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**

<ParamField path="includeSource" type="boolean" default="false" toc={true}>
  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"` (auto-generated
  at startup).
</ParamField>

## **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();
```