***

title: get_basic_auth_credentials
slug: /reference/python/agents/swml-service/get-basic-auth-credentials
description: Retrieve the HTTP Basic Auth credentials for the service.
max-toc-depth: 3
---------------------

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

[ref-swmlservice]: /docs/server-sdks/reference/python/agents/swml-service

Retrieve the current HTTP Basic Auth credentials used by this service. Every [SWMLService][ref-swmlservice]
instance has auth credentials — either explicitly provided in the constructor, read from
environment variables, or auto-generated at startup.

## **Parameters**

<ParamField path="include_source" type="bool" default="False" toc={true}>
  When `True`, returns a 3-tuple that includes the credential source as the third
  element. The source is one of:

  * `"environment"` — credentials came from `SWML_BASIC_AUTH_USER` and `SWML_BASIC_AUTH_PASSWORD` environment variables
  * `"auto-generated"` — credentials were randomly generated at startup
</ParamField>

## **Returns**

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

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

## **Example**

```python {6,10}
from signalwire import SWMLService

service = SWMLService(name="my-service")

# Get credentials
username, password = service.get_basic_auth_credentials()
print(f"Auth: {username}:{password}")

# Get credentials with source information
username, password, source = service.get_basic_auth_credentials(include_source=True)
print(f"Auth source: {source}")  # "environment" or "auto-generated"
```