# `ExMCP.Authorization.ErrorHandler`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/authorization/error_handler.ex#L1)

Handles authorization-related errors and triggers appropriate OAuth flows.

This module implements the MCP specification requirements for handling
401 Unauthorized and 403 Forbidden responses, automatically initiating
OAuth flows when needed.

# `handle_auth_error`

```elixir
@spec handle_auth_error(integer(), list(), binary(), map()) ::
  {:error, atom() | {atom(), any()}} | {:retry, map()}
```

Handles HTTP authorization errors according to MCP specification.

- 401 Unauthorized: Token is invalid or required
- 403 Forbidden: Insufficient permissions

Returns {:error, reason} or {:retry, auth_params} to trigger OAuth flow.

# `handle_oauth_error`

```elixir
@spec handle_oauth_error(map()) :: {:error, {atom(), String.t()}}
```

Processes an OAuth error response according to RFC 6749.

---

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