namespace ModelContextProtocol.Authentication;
///
/// Provides configuration options for the .
///
public sealed class ClientOAuthOptions
{
///
/// Gets or sets the OAuth redirect URI.
///
public required Uri RedirectUri { get; set; }
///
/// Gets or sets the OAuth client ID. If not provided, the client will attempt to register dynamically.
///
public string? ClientId { get; set; }
///
/// Gets or sets the OAuth client secret.
///
///
/// This secret is optional for public clients or when using PKCE without client authentication.
///
public string? ClientSecret { get; set; }
///
/// Gets or sets the HTTPS URL pointing to this client's metadata document.
///
///
/// When specified, and when the authorization server metadata reports
/// client_id_metadata_document_supported = true, the OAuth client will respond to
/// challenges by sending this URL as the client identifier instead of performing dynamic
/// client registration.
///
public Uri? ClientMetadataDocumentUri { get; set; }
///
/// Gets or sets the OAuth scopes to request.
///
///
///
/// When specified, these scopes will be used instead of the scopes advertised by the protected resource.
/// If not specified, the provider will use the scopes from the protected resource metadata.
///
///
/// Common OAuth scopes include "openid", "profile", and "email".
///
///
public IEnumerable? Scopes { get; set; }
///
/// Gets or sets the authorization redirect delegate for handling the OAuth authorization flow.
///
///
///
/// This delegate is responsible for handling the OAuth authorization URL and obtaining the authorization code.
/// If not specified, a default implementation will be used that prompts the user to enter the code manually.
///
///
/// Custom implementations might open a browser, start an HTTP listener, or use other mechanisms to capture
/// the authorization code from the OAuth redirect.
///
///
public AuthorizationRedirectDelegate? AuthorizationRedirectDelegate { get; set; }
///
/// Gets or sets the authorization server selector function.
///
///
///
/// This function is used to select which authorization server to use when multiple servers are available.
/// If not specified, the first available server will be selected.
///
///
/// The function receives a list of available authorization server URIs and should return the selected server,
/// or null if no suitable server is found.
///
///
public Func, Uri?>? AuthServerSelector { get; set; }
///
/// Gets or sets the options to use during dynamic client registration.
///
///
/// This value is only used when no is specified.
///
public DynamicClientRegistrationOptions? DynamicClientRegistration { get; set; }
///
/// Gets or sets additional parameters to include in the query string of the OAuth authorization request
/// providing extra information or fulfilling specific requirements of the OAuth provider.
///
///
///
/// Parameters specified cannot override or append to any automatically set parameters like the "redirect_uri",
/// which should instead be configured via .
///
///
public IDictionary AdditionalAuthorizationParameters { get; set; } = new Dictionary();
///
/// Gets or sets the token cache to use for storing and retrieving tokens beyond the lifetime of the transport.
/// If none is provided, tokens will be cached with the transport.
///
public ITokenCache? TokenCache { get; set; }
}