***

title: verify_bearer_token
slug: /reference/python/agents/configuration/auth-handler/verify-bearer-token
description: Verify a Bearer token using constant-time comparison.
max-toc-depth: 3
---------------------

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

[ref-securityconfig]: /docs/server-sdks/reference/python/agents/configuration/security-config

Verify a Bearer token using constant-time comparison.

## **Parameters**

<ParamField path="credentials" type="HTTPAuthorizationCredentials" required={true} toc={true}>
  FastAPI `HTTPAuthorizationCredentials` object containing the `credentials`
  (token) attribute.
</ParamField>

## **Returns**

`bool` -- `True` if the token matches the configured bearer token. Returns `False`
if bearer authentication is not enabled.

## **Example**

```python {9}
from fastapi.security import HTTPAuthorizationCredentials
from signalwire.core.security_config import SecurityConfig
from signalwire.core.auth_handler import AuthHandler

security = SecurityConfig()
auth = AuthHandler(security)

creds = HTTPAuthorizationCredentials(scheme="Bearer", credentials="my-token")
is_valid = auth.verify_bearer_token(creds)

print(f"Bearer token valid: {is_valid}")
```

<Note>
  Bearer token authentication is only available when the [`SecurityConfig`][ref-securityconfig] instance
  has a `bearer_token` attribute set (typically via config file).
</Note>