Generic OAuth 2.0 flow for service integrations.
Handles authorization URL generation, code-to-token exchange,
token refresh, and userinfo fetching. Provider-specific details
(URLs, scopes, extra params) come from the provider definition
in PhoenixKit.Integrations.Providers.
Summary
Functions
Build the OAuth authorization URL for a provider.
Exchange an authorization code for access and refresh tokens.
Fetch user info from the provider's userinfo endpoint.
Generate a random state token for CSRF protection in OAuth flows.
Refresh an expired access token using the refresh token.
Functions
@spec authorization_url(map(), map(), String.t(), String.t() | nil, String.t() | nil) :: {:ok, String.t()} | {:error, atom()}
Build the OAuth authorization URL for a provider.
Requires client_id to be present in the integration data and
the provider to have oauth_config with an auth_url.
Exchange an authorization code for access and refresh tokens.
Fetch user info from the provider's userinfo endpoint.
Returns a map with at least "email" if available.
@spec generate_state() :: String.t()
Generate a random state token for CSRF protection in OAuth flows.
Refresh an expired access token using the refresh token.