Sigra.OAuth.Strategies.Google (Sigra v1.20.0)

Copy Markdown View Source

Wraps Assent.Strategy.Google for Sigra OAuth integration.

Google uses OIDC with auto-discovery from .well-known/openid-configuration (D-18). Default scopes: openid, email, profile.

Summary

Functions

Generates the authorization URL for Google OAuth.

Handles the OAuth callback from Google.

Returns the default OAuth scopes for Google.

Verifies that the Assent library is available.

Normalizes a Google 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 Google OAuth.

Delegates to Assent.Strategy.Google'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 Google.

Delegates to Assent.Strategy.Google'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 Google.

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 Google user info map to a consistent shape.

Returns a map with keys: "sub", "email", "name", "picture", "email_verified", and "raw" (the original response).