Documentation Index Fetch the complete documentation index at: https://easyaf.dev/llms.txt
Use this file to discover all available pages before exploring further.
Definition
Assembly: Microsoft.OData.Mcp.Authentication.dll
Namespace: Microsoft.OData.Mcp.Authentication.Models
Inheritance: System.Object
Syntax
Microsoft . OData . Mcp . Authentication . Models . TokenValidationResult
Summary
Represents the result of a token validation operation.
This class encapsulates the outcome of token validation, including success/failure status,
the validated principal, and any validation errors that occurred during the process.
Constructors
.ctor
Initializes a new instance of the TokenValidationResult class.
Syntax
public TokenValidationResult ()
.ctor
Initializes a new instance of the TokenValidationResult class for a successful validation.
Syntax
public TokenValidationResult ( System . Security . Claims . ClaimsPrincipal principal )
Parameters
Name Type Description principalSystem.Security.Claims.ClaimsPrincipalThe validated claims principal.
Exceptions
Exception Description ArgumentNullExceptionThrown when principal is null.
.ctor
Initializes a new instance of the TokenValidationResult class for a failed validation.
Syntax
public TokenValidationResult ( string error , string errorDescription = null , System . Exception exception = null )
Parameters
Name Type Description errorstringThe validation error. errorDescriptionstring?The detailed error description. exceptionSystem.Exception?The exception that caused the failure.
Exceptions
Exception Description ArgumentExceptionThrown when error is null or whitespace.
.ctor Inherited
Syntax
Properties
Error
Gets or sets the validation error that occurred during token validation.
Syntax
public string Error { get ; set ; }
Property Value
Type: string?
The validation error if validation failed; otherwise, null.
This provides detailed information about why token validation failed,
which can be useful for debugging and security auditing.
ErrorDescription
Gets or sets the detailed error description.
Syntax
public string ErrorDescription { get ; set ; }
Property Value
Type: string?
A detailed description of the validation error; otherwise, null.
This provides additional context about the validation failure, such as
specific claims that were invalid or missing.
Exception
Gets or sets the exception that caused the validation failure.
Syntax
public System . Exception Exception { get ; set ; }
Property Value
Type: System.Exception?
The exception that occurred during validation; otherwise, null.
This is typically used for logging and debugging purposes to understand
the root cause of validation failures.
ExpiresAt
Gets or sets the token expiration time.
Syntax
public System . Nullable < System . DateTime > ExpiresAt { get ; set ; }
Property Value
Type: System.Nullable<System.DateTime?>?
The UTC date and time when the token expires; otherwise, null.
This is extracted from the token’s ‘exp’ claim and represents when the
token will no longer be valid for authentication.
IssuedAt
Gets or sets the token issued time.
Syntax
public System . Nullable < System . DateTime > IssuedAt { get ; set ; }
Property Value
Type: System.Nullable<System.DateTime?>?
The UTC date and time when the token was issued; otherwise, null.
This is extracted from the token’s ‘iat’ claim and represents when the
token was originally created by the authorization server.
IsValid
Gets or sets a value indicating whether the token validation was successful.
Syntax
public bool IsValid { get ; set ; }
Property Value
Type: bool
true if the token is valid; otherwise, false.
Gets or sets additional validation metadata.
Syntax
public System . Collections . Generic . Dictionary < string , object > Metadata { get ; set ; }
Property Value
Type: System.Collections.Generic.Dictionary<string, object>
A dictionary of additional information about the validation process.
This can include information such as the validation time, token issuer,
audience, or other metadata that might be useful for auditing or debugging.
NotBefore
Gets or sets the token not-before time.
Syntax
public System . Nullable < System . DateTime > NotBefore { get ; set ; }
Property Value
Type: System.Nullable<System.DateTime?>?
The UTC date and time before which the token is not valid; otherwise, null.
This is extracted from the token’s ‘nbf’ claim and represents the earliest
time the token can be used for authentication.
Principal
Gets or sets the claims principal from the validated token.
Syntax
public System . Security . Claims . ClaimsPrincipal Principal { get ; set ; }
Property Value
Type: System.Security.Claims.ClaimsPrincipal?
The claims principal if validation was successful; otherwise, null.
This principal contains all the claims extracted from the JWT token and can be
used for authorization decisions and user context extraction.
Methods
Adds metadata to the validation result.
Syntax
public void AddMetadata ( string key , object value )
Parameters
Name Type Description keystringThe metadata key. valueobjectThe metadata value.
Exceptions
Exception Description ArgumentExceptionThrown when key is null or whitespace.
Equals Inherited Virtual
Syntax
public virtual bool Equals ( object obj )
Parameters
Name Type Description objobject?-
Returns
Type: bool
Equals Inherited
Syntax
public static bool Equals ( object objA , object objB )
Parameters
Name Type Description objAobject?- objBobject?-
Returns
Type: bool
Failure
Creates a failed validation result.
Syntax
public static Microsoft . OData . Mcp . Authentication . Models . TokenValidationResult Failure ( string error , string errorDescription = null , System . Exception exception = null )
Parameters
Name Type Description errorstringThe validation error. errorDescriptionstring?The detailed error description. exceptionSystem.Exception?The exception that caused the failure.
Returns
Type: Microsoft.OData.Mcp.Authentication.Models.TokenValidationResult
A failed token validation result.
Exceptions
Exception Description ArgumentExceptionThrown when error is null or whitespace.
GetHashCode Inherited Virtual
Syntax
public virtual int GetHashCode ()
Returns
Type: int
Gets metadata value by key.
Syntax
public T GetMetadata < T >( string key )
Parameters
Name Type Description keystringThe metadata key.
Returns
Type: T?
The metadata value if found and of the correct type; otherwise, the default value.
Type Parameters
T - The type of the metadata value.
GetRemainingLifetime
Gets the remaining lifetime of the token.
Syntax
public System . Nullable < System . TimeSpan > GetRemainingLifetime ()
Returns
Type: System.Nullable<System.TimeSpan?>?
The remaining time before the token expires, or null if no expiration is set.
GetType Inherited
Syntax
public System . Type GetType ()
Returns
Type: System.Type
IsExpired
Determines whether the token is currently expired.
Syntax
Returns
Type: bool
true if the token is expired; otherwise, false.
IsNotYetValid
Determines whether the token is not yet valid.
Syntax
public bool IsNotYetValid ()
Returns
Type: bool
true if the token is not yet valid; otherwise, false.
MemberwiseClone Inherited
Syntax
protected internal object MemberwiseClone ()
Returns
Type: object
ReferenceEquals Inherited
Syntax
public static bool ReferenceEquals ( object objA , object objB )
Parameters
Name Type Description objAobject?- objBobject?-
Returns
Type: bool
Success
Creates a successful validation result.
Syntax
public static Microsoft . OData . Mcp . Authentication . Models . TokenValidationResult Success ( System . Security . Claims . ClaimsPrincipal principal )
Parameters
Name Type Description principalSystem.Security.Claims.ClaimsPrincipalThe validated claims principal.
Returns
Type: Microsoft.OData.Mcp.Authentication.Models.TokenValidationResult
A successful token validation result.
Exceptions
Exception Description ArgumentNullExceptionThrown when principal is null.
ToString Override
Returns a string representation of the token validation result.
Syntax
public override string ToString ()
Returns
Type: string
A summary of the validation result.
ToString Inherited Virtual
Syntax
public virtual string ToString ()
Returns
Type: string?