# `Pixir.Auth.CallbackServer`
[🔗](https://github.com/Ranvier-Technologies/pixir/blob/main/lib/pixir/auth/callback_server.ex#L1)

Short-lived localhost HTTP server for the Codex browser OAuth callback (ADR 0002).

Binds `127.0.0.1:1455` by default, accepts a single `/auth/callback` request, validates
the OAuth `state`, and returns the authorization `code`. The registered redirect URI
uses `localhost` (Pi/Codex convention) even though the listener binds to loopback.

# `listen_socket`

```elixir
@type listen_socket() :: port()
```

# `close`

```elixir
@spec close(listen_socket()) :: :ok
```

Close the listen socket.

# `listen`

```elixir
@spec listen(keyword()) :: {:ok, listen_socket()} | {:error, map()}
```

Start listening for one browser callback. Accepts `:host`, `:port` (testing).

# `redirect_uri`

```elixir
@spec redirect_uri() :: String.t()
```

Registered OAuth redirect URI for the browser flow.

# `wait_for_callback`

```elixir
@spec wait_for_callback(
  listen_socket(),
  keyword()
) :: {:ok, String.t()} | {:error, map()}
```

Accept one callback connection and return the authorization code.

Options: `:state` (required), `:timeout_ms` (default 15 min).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
