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.Services
Syntax
Microsoft . OData . Mcp . Authentication . Services . ITokenDelegationService
Summary
Provides services for delegating authentication tokens to downstream services.
This service handles the complexities of token delegation, including token forwarding,
exchange, and on-behalf-of flows. It ensures that user identity is preserved while
enabling secure communication with downstream OData services.
Methods
ClearCachedTokensAsync Abstract
Clears all cached tokens for a specific user.
Syntax
System . Threading . Tasks . Task ClearCachedTokensAsync ( string userId , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
userIdstringThe user identifier. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task
A task that represents the asynchronous operation.
Exceptions
Exception Description
ArgumentExceptionThrown when userId is null or whitespace.
ExchangeTokenAsync Abstract
Exchanges a token for a new token with different scopes or audience.
Syntax
System . Threading . Tasks . Task < Microsoft . OData . Mcp . Authentication . Models . DelegatedToken > ExchangeTokenAsync ( string originalToken , string targetAudience , System . Collections . Generic . IEnumerable < string > requestedScopes = null , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
originalTokenstringThe original token to exchange. targetAudiencestringThe audience for the new token. requestedScopesSystem.Collections.Generic.IEnumerable<string>?The scopes to request for the new token. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Authentication.Models.DelegatedToken>
A task that represents the asynchronous operation. The task result contains the exchanged token.
Exceptions
Exception Description
ArgumentExceptionThrown when originalToken or targetAudience is null or whitespace.
GetCachedTokenAsync Abstract
Gets the cached token for a specific service and user, if available.
Syntax
System . Threading . Tasks . Task < Microsoft . OData . Mcp . Authentication . Models . DelegatedToken > GetCachedTokenAsync ( string userId , string targetServiceId , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
userIdstringThe user identifier. targetServiceIdstringThe target service identifier. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Authentication.Models.DelegatedToken?>
A task that represents the asynchronous operation. The task result contains the cached token, or null if not found.
Exceptions
Exception Description
ArgumentExceptionThrown when userId or targetServiceId is null or whitespace.
GetOnBehalfOfTokenAsync Abstract
Performs an OAuth2 on-behalf-of flow to get a token for a downstream service.
Syntax
System . Threading . Tasks . Task < Microsoft . OData . Mcp . Authentication . Models . DelegatedToken > GetOnBehalfOfTokenAsync ( string originalToken , string targetAudience , Microsoft . OData . Mcp . Authentication . Models . ClientCredentials clientCredentials , System . Collections . Generic . IEnumerable < string > requestedScopes = null , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
originalTokenstringThe original user token. targetAudiencestringThe audience for the new token. clientCredentialsMicrosoft.OData.Mcp.Authentication.Models.ClientCredentialsThe client credentials for the on-behalf-of flow. requestedScopesSystem.Collections.Generic.IEnumerable<string>?The scopes to request for the new token. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Authentication.Models.DelegatedToken>
A task that represents the asynchronous operation. The task result contains the on-behalf-of token.
Exceptions
Exception Description
ArgumentExceptionThrown when originalToken or targetAudience is null or whitespace. ArgumentNullExceptionThrown when clientCredentials is null.
GetTokenForServiceAsync Abstract
Gets an authentication token for making requests to a specific target service.
Syntax
System . Threading . Tasks . Task < Microsoft . OData . Mcp . Authentication . Models . DelegatedToken > GetTokenForServiceAsync ( string originalToken , string targetServiceId , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
originalTokenstringThe original user token. targetServiceIdstringThe identifier of the target service. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Authentication.Models.DelegatedToken>
A task that represents the asynchronous operation. The task result contains the delegated token.
Exceptions
Exception Description
ArgumentExceptionThrown when originalToken or targetServiceId is null or whitespace.
GetTokenForUrlAsync Abstract
Gets an authentication token for making requests to a target URL.
Syntax
System . Threading . Tasks . Task < Microsoft . OData . Mcp . Authentication . Models . DelegatedToken > GetTokenForUrlAsync ( string originalToken , string targetUrl , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
originalTokenstringThe original user token. targetUrlstringThe URL of the target service. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Authentication.Models.DelegatedToken>
A task that represents the asynchronous operation. The task result contains the delegated token.
Exceptions
Exception Description
ArgumentExceptionThrown when originalToken or targetUrl is null or whitespace.
RefreshTokenAsync Abstract
Refreshes a delegated token if it supports refresh operations.
Syntax
System . Threading . Tasks . Task < Microsoft . OData . Mcp . Authentication . Models . DelegatedToken > RefreshTokenAsync ( Microsoft . OData . Mcp . Authentication . Models . DelegatedToken delegatedToken , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
delegatedTokenMicrosoft.OData.Mcp.Authentication.Models.DelegatedTokenThe delegated token to refresh. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task<Microsoft.OData.Mcp.Authentication.Models.DelegatedToken>
A task that represents the asynchronous operation. The task result contains the refreshed token.
Exceptions
Exception Description
ArgumentNullExceptionThrown when delegatedToken is null.
RevokeTokenAsync Abstract
Revokes a delegated token if the target service supports token revocation.
Syntax
System . Threading . Tasks . Task RevokeTokenAsync ( Microsoft . OData . Mcp . Authentication . Models . DelegatedToken delegatedToken , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
delegatedTokenMicrosoft.OData.Mcp.Authentication.Models.DelegatedTokenThe delegated token to revoke. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task
A task that represents the asynchronous operation.
Exceptions
Exception Description
ArgumentNullExceptionThrown when delegatedToken is null.
ValidateTokenForDelegationAsync Abstract
Validates that a token is suitable for delegation to a specific service.
Syntax
System . Threading . Tasks . Task < bool > ValidateTokenForDelegationAsync ( string token , string targetServiceId , System . Threading . CancellationToken cancellationToken = null )
Parameters
Name Type Description
tokenstringThe token to validate for delegation. targetServiceIdstringThe identifier of the target service. cancellationTokenSystem.Threading.CancellationTokenA cancellation token to cancel the operation.
Returns
Type: System.Threading.Tasks.Task<bool>
A task that represents the asynchronous operation. The task result indicates whether the token is valid for delegation.
Exceptions
Exception Description
ArgumentExceptionThrown when token or targetServiceId is null or whitespace.