GoodAnalytics.Api.AuthPlug (GoodAnalytics v0.1.1)

Copy Markdown View Source

Authenticates API requests via a host-app-provided callback.

Extracts a Bearer token or API key from request headers, invokes the configured :api_authenticate callback, and assigns workspace_id and auth_context to the connection on success.

Configuration

config :good_analytics, :api_authenticate, {MyApp.Auth, :authenticate_ga_api}

The callback must be arity-2: (token, type) where type is :bearer or :api_key. It must return {:ok, %{workspace_id: uuid, ...}} on success or {:error, reason} on failure.