***

title: get_basic_auth_credentials
slug: /reference/python/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="include_source" type="bool" 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**

`tuple[str, str]` -- `(username, password)` when `include_source` is `False`.

`tuple[str, str, str]` -- `(username, password, source)` when `include_source` is
`True`.

## **Examples**

### Log credentials at startup

```python {5}
from signalwire import AgentBase

agent = AgentBase(name="assistant", route="/assistant")
agent.set_prompt_text("You are a helpful assistant.")
user, password = agent.get_basic_auth_credentials()
print(f"Auth: {user}:{password}")
agent.serve()
```

### Check credential source

```python {5}
from signalwire import AgentBase

agent = AgentBase(name="assistant", route="/assistant")
agent.set_prompt_text("You are a helpful assistant.")
user, password, source = agent.get_basic_auth_credentials(include_source=True)
if source == "generated":
    print(f"Auto-generated credentials: {user}:{password}")
    print("Set SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD to use your own.")
agent.serve()
```