ProtoRune.Atproto.OAuth.Client (proto_rune v0.3.0)

Copy Markdown

An AT Protocol OAuth public client.

Holds the client configuration used across the authorization flow: the client_id (a URL pointing to the client metadata document), the redirect_uri registered in that document, the requested scope and the DPoP key pair used to prove possession of issued tokens.

Build one with new/1 and pass it to the functions in ProtoRune.Atproto.OAuth.

Client metadata

AT Protocol public clients identify themselves with a client_id URL that serves a client metadata document (RFC 7591 style). See https://atproto.com/specs/oauth for the required fields.

Examples

{:ok, client} =
  Client.new(
    client_id: "https://myapp.example.com/oauth/client-metadata.json",
    redirect_uri: "https://myapp.example.com/oauth/callback"
  )

Summary

Functions

Creates a new OAuth client.

Types

t()

@type t() :: %ProtoRune.Atproto.OAuth.Client{
  client_id: String.t(),
  dpop_jwk: ProtoRune.Atproto.OAuth.DPoP.jwk(),
  dpop_key: ProtoRune.Atproto.OAuth.DPoP.private_key(),
  redirect_uri: String.t(),
  scope: String.t()
}

Functions

new(opts)

@spec new(keyword()) ::
  {:ok, t()} | {:error, :missing_client_id | :missing_redirect_uri}

Creates a new OAuth client.

Options

  • :client_id - Required. URL of the client metadata document.
  • :redirect_uri - Required. Callback URL registered in the client metadata.
  • :scope - Requested scope (default: "atproto transition:generic").
  • :dpop_key - Existing 32-byte ES256 private key. When omitted, a fresh key pair is generated.