FalEx.Auth (fal_ex v0.1.0)

View Source

Authentication module for FalEx client.

Handles API key authentication and temporary token generation for browser/realtime clients.

Summary

Functions

Generates a temporary authentication token for browser/realtime usage.

Gets the base authentication headers for a request.

Checks if credentials are present in the configuration.

Generates authentication headers based on the provided credentials.

Functions

create_temporary_token(config, opts \\ [])

Generates a temporary authentication token for browser/realtime usage.

This is used when connecting to streaming or WebSocket endpoints from environments where exposing the main API key would be insecure.

Options

  • :allowed_apps - List of allowed app IDs (default: ["*"])
  • :token_expiration - Token expiration time in seconds (default: 120)

Examples

iex> {:ok, token} = FalEx.Auth.create_temporary_token(config)
iex> is_binary(token)
true

get_request_headers(config)

Gets the base authentication headers for a request.

Includes credentials if present and not using a proxy.

has_credentials?(config)

Checks if credentials are present in the configuration.

to_headers(api_key)

Generates authentication headers based on the provided credentials.

Examples

iex> FalEx.Auth.to_headers("key_123456")
[{"Authorization", "Key key_123456"}]

iex> FalEx.Auth.to_headers({"id_123", "secret_456"})
[{"Authorization", "Key id_123:secret_456"}]