PhoenixKit.Users.OAuthConfig (phoenix_kit v1.6.16)
View SourceRuntime 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.
Summary
Functions
Configures a specific OAuth provider from database settings.
Configures all OAuth providers from database settings.
Tests OAuth connection for a specific provider.
Validates OAuth credentials for a specific provider.
Functions
Configures a specific OAuth provider from database settings.
Examples
iex> PhoenixKit.Users.OAuthConfig.configure_provider(:google)
:ok
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
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"}
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"}