Search documentation of phoenix_kit

# PhoenixKit.Workers.OAuthConfigLoader (phoenix_kit v1.7.87)

Copy Markdown View Source

GenServer worker that ensures OAuth configuration is loaded from database before any OAuth requests are processed.

This worker runs synchronously during application startup to configure OAuth providers from database settings.

## Startup Sequence

1. PhoenixKit.Cache starts with sync_init, loading critical OAuth settings
2. OAuthConfigLoader starts, OAuth settings already in cache
3. Loads OAuth configuration from cache
4. Configures Ueberauth with available providers
5. Returns :ok when complete

## Why This Is Needed

Parent applications typically start services in this order:

- Repo (database ready)
- PubSub
- Parent Endpoint (router compiles, Ueberauth.init() runs)
- PhoenixKit.Supervisor (OAuth config should load here)

With sync_init enabled in the Cache, critical OAuth settings are loaded synchronously before this worker starts, eliminating race conditions.

This worker ensures OAuth configuration is available as early as possible during PhoenixKit.Supervisor initialization.

## Summary

### Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

get_status()

Gets the current status of OAuth configuration.

reload_config()

Attempts to reload OAuth configuration.

start_link(opts)

Starts the OAuth configuration loader.

## Functions

# child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# get_status()

Gets the current status of OAuth configuration.

Returns:

- `{:ok, :loaded}` - Configuration successfully loaded
- `{:ok, :not_loaded, reason}` - Configuration not loaded with reason
- `{:error, :not_running}` - OAuthConfigLoader is not running

# reload_config()

Attempts to reload OAuth configuration.

This can be called to retry loading configuration if it failed during startup.

# start_link(opts)

Starts the OAuth configuration loader.

Loads OAuth configuration from cache which is pre-warmed with critical settings.