# `PhoenixKit.Users.OAuthConfig`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.111/lib/phoenix_kit/users/oauth_config.ex#L1)

Runtime OAuth configuration management using database credentials.

This module provides functions to configure OAuth providers at runtime
by reading credentials from the database and updating the application
configuration dynamically.

# `configure_provider`

Configures a specific OAuth provider from database settings.

## Examples

    iex> PhoenixKit.Users.OAuthConfig.configure_provider(:google)
    :ok

# `configure_providers`

Configures all OAuth providers from database settings.

This function reads OAuth credentials from the database and updates
the application configuration at runtime. It should be called:
- On application startup
- After updating OAuth credentials via admin UI

Skips configuration if OAuth is disabled in settings (oauth_enabled = false).

## Examples

    iex> PhoenixKit.Users.OAuthConfig.configure_providers()
    :ok

# `test_connection`

Tests OAuth connection for a specific provider.

This function validates the credentials format but does not make actual API calls.
For true connection testing, OAuth flow needs to be initiated through the browser.

## Examples

    iex> PhoenixKit.Users.OAuthConfig.test_connection(:google)
    {:ok, "Google OAuth credentials are properly formatted"}

# `validate_credentials`

Validates OAuth credentials for a specific provider.

Returns `{:ok, provider}` if credentials are valid, or `{:error, reason}` if not.
Uses direct database read for accurate validation.

## Examples

    iex> PhoenixKit.Users.OAuthConfig.validate_credentials(:google)
    {:ok, :google}

    iex> PhoenixKit.Users.OAuthConfig.validate_credentials(:apple)
    {:error, "Missing Apple private key"}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
