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

# validateBasicAuth

> Validate basic-auth credentials against the configured ones (constant-time).

[get-basic-auth-credentials]: /docs/server-sdks/reference/typescript/agents/swml-service/get-basic-auth-credentials

Validate a supplied username/password pair against the service's configured
Basic Auth credentials using a constant-time comparison, so the secret is not
leaked through timing. Returns `false` when no credentials are configured.

## **Parameters**

Username to compare against the configured credentials.

Password to compare against the configured credentials.

## **Returns**

`boolean | Promise<boolean>` -- `true` when both values match the configured
credentials; `false` when they do not match or no credentials are set.

## **Example**

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

const service = new SWMLService({ name: 'my-service', basicAuth: ['user', 'secret'] });

const ok = service.validateBasicAuth('user', 'secret');
console.log(ok); // true
```

Retrieve the configured credentials with
[`getBasicAuthCredentials()`][get-basic-auth-credentials].