Sigra.OAuth.Strategies.Facebook (Sigra v0.2.5)

Copy Markdown View Source

Wraps Assent.Strategy.Facebook for Sigra OAuth integration.

Facebook uses standard OAuth2. Default scopes: email, public_profile.

Important: Facebook does NOT verify email addresses (Pitfall 1 from RESEARCH.md). normalize_user/1 always forces "email_verified" => false regardless of what Facebook returns. Downstream code must honor this flag and require email confirmation for Facebook-authenticated users.

Summary

Functions

Generates the authorization URL for Facebook OAuth.

Handles the OAuth callback from Facebook.

Returns the default OAuth scopes for Facebook.

Verifies that the Assent library is available.

Normalizes a Facebook user info map to a consistent shape.

Functions

authorize_url(provider_config)

(since 0.1.0)
@spec authorize_url(keyword()) :: {:ok, map()} | {:error, term()}

Generates the authorization URL for Facebook OAuth.

Delegates to Assent.Strategy.Facebook's authorize_url function with merged config.

callback(provider_config, params, session_params)

(since 0.1.0)
@spec callback(keyword(), map(), map()) :: {:ok, map(), map()} | {:error, term()}

Handles the OAuth callback from Facebook.

Delegates to Assent.Strategy.Facebook's callback function and normalizes the user info.

default_scopes()

(since 0.1.0)
@spec default_scopes() :: [String.t()]

Returns the default OAuth scopes for Facebook.

ensure_assent!()

(since 0.1.0)
@spec ensure_assent!() :: :ok

Verifies that the Assent library is available.

Raises a descriptive error if Assent is not loaded (D-14). Returns :ok if available.

normalize_user(user)

(since 0.1.0)
@spec normalize_user(map()) :: map()

Normalizes a Facebook user info map to a consistent shape.

Always forces "email_verified" => false because Facebook does not verify email addresses. Falls back to to_string(user["id"]) when "sub" is nil.