WebsockexNova.Defaults.DefaultAuthHandler (WebsockexNova v0.1.1)
View SourceDefault implementation of the AuthHandler behavior.
This module provides sensible default implementations for all AuthHandler callbacks, including:
- Basic token-based authentication
- Automatic token expiration tracking
- Credential management
- Authentication status tracking
Usage
You can use this module directly or as a starting point for your own implementation:
defmodule MyApp.CustomAuthHandler do
use WebsockexNova.Defaults.DefaultAuthHandler
# Override specific callbacks as needed
def generate_auth_data(state) do
# Custom auth data generation
{:ok, auth_data, state}
end
end
Configuration
The default handler expects the following configuration in adapter_state:
:credentials
- Map containing authentication credentials (required):api_key
- API key or client ID:secret
- API secret or password
:auth_status
- Current authentication status (default: :unauthenticated):auth_expires_at
- Unix timestamp when the authentication token expires (optional):auth_refresh_threshold
- Seconds before expiry to trigger reauthentication (default: 60)