Sigra.OAuth.Strategies.Generic (Sigra v0.2.2)

Copy Markdown View Source

Generic fallback strategy wrapper for any Assent strategy (D-13).

Delegates to the Assent strategy module specified via the :strategy key in the provider config. This allows any Assent-supported provider to work with Sigra without a dedicated wrapper.

Example

# In config.exs:
config :my_app, Sigra,
  oauth: [
    providers: [
      discord: [
        strategy: Assent.Strategy.Discord,
        client_id: "...",
        client_secret: "..."
      ]
    ]
  ]

Summary

Functions

Generates the authorization URL using the configured Assent strategy.

Handles the OAuth callback using the configured Assent strategy.

Verifies that the Assent library is available.

Normalizes a generic provider 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 using the configured Assent strategy.

Requires :strategy key in config pointing to an Assent strategy module.

callback(provider_config, params, session_params)

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

Handles the OAuth callback using the configured Assent strategy.

Requires :strategy key in config pointing to an Assent strategy module.

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