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

# verifyBasicAuth

> Verify a username/password pair against the configured Basic Auth credentials.

[ref-validate]: /docs/server-sdks/reference/typescript/agents/configuration/auth-handler/validate

[ref-middleware]: /docs/server-sdks/reference/typescript/agents/configuration/auth-handler/middleware

Verify a Basic Auth username/password pair against the configured credentials.
Uses a constant-time comparison to prevent timing attacks. Useful for custom
auth flows where you need to check credentials outside a middleware context.

<Note>
  Returns `false` immediately when Basic Auth is not configured (i.e.,
  `basicAuth` was not passed to the constructor). For full request validation
  including Bearer and API key fallbacks, use
  [`validate()`][ref-validate] or attach
  [`middleware()`][ref-middleware] to your Hono app.
</Note>

## **Parameters**

<ParamField path="username" type="string" required={true} toc={true}>
  The username to verify.
</ParamField>

<ParamField path="password" type="string" required={true} toc={true}>
  The password to verify.
</ParamField>

## **Returns**

`boolean` -- `true` if the credentials match; `false` if they don't, or if
Basic Auth was not configured.

## **Example**

```typescript {12}
import { AuthHandler } from '@signalwire/sdk';

const auth = new AuthHandler({
  basicAuth: ['admin', 'secret-password'],
});

function login(username: string, password: string) {
  if (auth.verifyBasicAuth(username, password)) {
    return { ok: true, user: username };
  }
  return { ok: false };
}
```