Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Authentication.dll Namespace: Microsoft.OData.Mcp.Authentication.Models Inheritance: System.Object

Syntax

Microsoft.OData.Mcp.Authentication.Models.ClientCredentials

Summary

Represents client credentials for OAuth2 authentication.

Remarks

These credentials identify the MCP server to authorization servers when performing OAuth2 flows that require client authentication, such as token exchange or on-behalf-of flows.

Constructors

.ctor

Initializes a new instance of the ClientCredentials class.

Syntax

public ClientCredentials()

.ctor

Initializes a new instance of the ClientCredentials class with client secret authentication.

Syntax

public ClientCredentials(string clientId, string clientSecret)

Parameters

NameTypeDescription
clientIdstringThe client identifier.
clientSecretstringThe client secret.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when clientId or clientSecret is null or whitespace.

.ctor

Initializes a new instance of the ClientCredentials class with certificate authentication.

Syntax

public ClientCredentials(string clientId, Microsoft.OData.Mcp.Authentication.Models.ClientCertificate certificate)

Parameters

NameTypeDescription
clientIdstringThe client identifier.
certificateMicrosoft.OData.Mcp.Authentication.Models.ClientCertificateThe client certificate configuration.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when clientId is null or whitespace.
ArgumentNullExceptionThrown when certificate is null.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

AuthenticationMethod

Gets or sets the client authentication method.

Syntax

public Microsoft.OData.Mcp.Authentication.Models.ClientAuthenticationMethod AuthenticationMethod { get; set; }

Property Value

Type: Microsoft.OData.Mcp.Authentication.Models.ClientAuthenticationMethod? The method used to authenticate the client to the authorization server.

Remarks

Different authorization servers support different client authentication methods. The most common are client secrets and certificate-based authentication.

Certificate

Gets or sets the certificate for certificate-based authentication.

Syntax

public Microsoft.OData.Mcp.Authentication.Models.ClientCertificate Certificate { get; set; }

Property Value

Type: Microsoft.OData.Mcp.Authentication.Models.ClientCertificate? Configuration for client certificate authentication.

Remarks

This certificate is used when the authentication method requires certificate-based authentication. It provides a more secure alternative to client secrets.

ClientAssertion

Gets or sets the assertion for JWT-based client authentication.

Syntax

public string ClientAssertion { get; set; }

Property Value

Type: string? The JWT assertion used for client authentication.

Remarks

This is used when the authentication method is PrivateKeyJwt or ClientSecretJwt. The assertion must be properly signed and contain the required claims.

ClientAssertionType

Gets or sets the assertion type for JWT-based client authentication.

Syntax

public string ClientAssertionType { get; set; }

Property Value

Type: string? The type of the client assertion.

Remarks

This is typically “urn:ietf:params:oauth:client-assertion-type:jwt-bearer” for JWT-based client authentication methods.

ClientId

Gets or sets the client identifier.

Syntax

public required string ClientId { get; set; }

Property Value

Type: string The client ID registered with the authorization server.

Remarks

The client ID uniquely identifies the MCP server application to the authorization server. It is typically a GUID or other unique string assigned during application registration.

ClientSecret

Gets or sets the client secret for secret-based authentication.

Syntax

public string ClientSecret { get; set; }

Property Value

Type: string? The client secret registered with the authorization server.

Remarks

This secret is used when the authentication method is ClientSecret or ClientSecretPost. It should be kept secure and rotated regularly for security best practices.

Methods

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Override

Returns a string representation of the client credentials.

Syntax

public override string ToString()

Returns

Type: string A summary of the client credentials configuration.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

Validate

Validates the client credentials for consistency and completeness.

Syntax

public System.Collections.Generic.IEnumerable<string> Validate()

Returns

Type: System.Collections.Generic.IEnumerable<string> A collection of validation errors, or an empty collection if the credentials are valid.