Skip to main content
For authentication beyond Bearer tokens and OAuth, pass any httpx.Auth object to get full control over request authentication.

Built-in Options

HTTP Basic Auth encodes username:password in Base64:

Custom Implementations

Create your own by subclassing httpx.Auth:
For APIs requiring request signatures:
Add several authentication headers at once:

Combining with Headers

You can use both auth and headers together:
The auth object handles dynamic authentication while headers adds static headers to every request.

When to Use What

When implementing custom auth:
  • Never log credentials
  • Use hmac.compare_digest for signature comparison
  • Store secrets in environment variables