ExMCP.Authorization.HTTPClient (ex_mcp v0.9.2)

View Source

HTTP client functionality for OAuth 2.1 requests.

This module handles the HTTP communication with OAuth authorization servers, including token requests, introspection, and metadata discovery.

Summary

Functions

Fetches server metadata from the well-known endpoint.

Makes a token introspection request.

Makes a token request to the authorization server.

Functions

fetch_server_metadata(metadata_url)

@spec fetch_server_metadata(String.t()) :: {:ok, map()} | {:error, term()}

Fetches server metadata from the well-known endpoint.

Implements RFC 8414 OAuth 2.0 Authorization Server Metadata discovery.

make_introspection_request(endpoint, body)

@spec make_introspection_request(String.t(), map()) :: {:ok, map()} | {:error, term()}

Makes a token introspection request.

Used for validating access tokens with the authorization server.

make_token_request(endpoint, body, opts \\ [])

@spec make_token_request(
  String.t(),
  keyword() | [{String.t(), String.t()}],
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Makes a token request to the authorization server.

Handles both token exchange and refresh token requests with proper error handling and response parsing.