# `AshAi.Mcp.OAuth.Client`
[🔗](https://github.com/ash-project/ash_ai/blob/v1.5.6/lib/ash_ai/mcp/oauth/client.ex#L5)

An OAuth client registered with one authorization server.

`:source` says how the client was obtained:

- `:pre_registered` - supplied by the application through `:pre_registered`.
- `:cimd` - a Client ID Metadata Document; `client_id` is the document's URL.
- `:dcr` - registered through Dynamic Client Registration (RFC 7591) and
  persisted with `c:AshAi.Mcp.OAuth.Store.put_client/3`.

Credentials belong to the authorization server that issued them, named by
`:issuer`.

# `t`

```elixir
@type t() :: %AshAi.Mcp.OAuth.Client{
  client_id: String.t(),
  client_secret: String.t() | nil,
  client_secret_expires_at: DateTime.t() | nil,
  issuer: String.t(),
  redirect_uris: [String.t()],
  registration_access_token: String.t() | nil,
  registration_client_uri: String.t() | nil,
  source: :pre_registered | :cimd | :dcr,
  token_endpoint_auth_method: String.t()
}
```

# `from_map`

```elixir
@spec from_map(map()) :: t()
```

Builds a client from a map produced by `to_map/1`.

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts the client to a JSON-safe map with string keys.

---

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