Supabase.Auth.Schemas.OAuth.AuthorizationDetails (supabase_auth v1.0.1)

View Source

Schema for OAuth authorization request details using schemaless changesets.

Contains information about an OAuth authorization request, including the requesting client, user, and requested scopes.

Early-Exit Scenario

If the redirect_url field is present, the user has already consented to this authorization request and should be redirected immediately without showing a consent screen.

Examples

# User needs to provide consent
%{
  authorization_id: "auth-123",
  redirect_url: nil,
  client: %{id: "client-123", name: "My App", ...},
  user: %{id: "user-123", email: "user@example.com"},
  scope: "read write"
}

# User already consented (early-exit)
%{
  authorization_id: "auth-123",
  redirect_url: "https://app.com/callback?code=...",
  client: %{...},
  user: %{...},
  scope: "read write"
}

Summary

Functions

Parses OAuth authorization details from API response.

Types

t()

@type t() :: %{
  authorization_id: String.t(),
  redirect_url: String.t() | nil,
  client: Supabase.Auth.Schemas.OAuth.Client.t(),
  user: %{id: String.t(), email: String.t()},
  scope: String.t()
}

Functions

parse(attrs)

@spec parse(map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Parses OAuth authorization details from API response.

Returns {:ok, map} with parsed authorization details or {:error, changeset} if validation fails.

Examples

iex> AuthorizationDetails.parse(%{
...>   "authorization_id" => "auth-123",
...>   "redirect_url" => nil,
...>   "client" => %{"id" => "c1", "name" => "App", "uri" => "https://app.com"},
...>   "user" => %{"id" => "u1", "email" => "user@example.com"},
...>   "scope" => "read write"
...> })
{:ok, %{
  authorization_id: "auth-123",
  redirect_url: nil,
  client: %{id: "c1", name: "App", uri: "https://app.com", logo_uri: nil},
  user: %{id: "u1", email: "user@example.com"},
  scope: "read write"
}}