# `Sake.Client.Auth.Browser`
[🔗](https://github.com/hattoriai/sake/blob/v0.4.3/lib/sake/client/auth/browser.ex#L1)

Authorizes in the person's browser: opens the authorization URL with the
system's opener (`open` on macOS, `xdg-open` elsewhere on Unix,
`rundll32` on Windows) and waits for the redirect on a one-shot HTTP
listener at the redirect URI's loopback address and port (RFC 8252
§7.3). The default in `Sake.Client.Auth`.

The redirect URI must be plain `http` on `127.0.0.1`, `[::1]` or
`localhost` (which listens on `127.0.0.1`; RFC 8252 §8.3 prefers the
literal address), with the port the listener can bind. The listener
answers the browser with a short page saying the window can be closed,
and stops after the redirect or after five minutes.

    auth: [authorize: &Sake.Client.Auth.Browser.authorize(&1, timeout: 120_000)]

# `authorize`

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

Opens `url` and returns the parameters of the redirect. `opts`:
`timeout:` (milliseconds, default five minutes), `open:` (a function of
the URL that shows it to the person, instead of the system's opener).

---

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