Language

UserAuthorization.ExchangeTurnTokenAsTokenCredential Method

Definition

Creates a token credential that exchanges the user token for scopes requested during the current turn.

public Azure.Core.TokenCredential ExchangeTurnTokenAsTokenCredential(Microsoft.Agents.Builder.ITurnContext turnContext, string handlerName = default, string exchangeConnection = default, System.Collections.Generic.IList<string> exchangeScopes = default);
member this.ExchangeTurnTokenAsTokenCredential : Microsoft.Agents.Builder.ITurnContext * string * string * System.Collections.Generic.IList<string> -> Azure.Core.TokenCredential
Public Function ExchangeTurnTokenAsTokenCredential (turnContext As ITurnContext, Optional handlerName As String = Nothing, Optional exchangeConnection As String = Nothing, Optional exchangeScopes As IList(Of String) = Nothing) As TokenCredential

Parameters

turnContext
ITurnContext

The current turn context.

handlerName
String

The user authorization handler name, or null to use the default handler.

exchangeConnection
String

The connection used for token exchange, or null to use the handler's configured connection.

exchangeScopes
IList<String>

Additional scopes to include in every token exchange.

Returns

A token credential that exchanges the current turn's user token for requested scopes.

Remarks

The returned credential is scoped to turnContext and must only be used during that turn. Do not cache it or provide it to a client that outlives the turn. Create a new credential in each turn instead. Scopes requested from the credential are combined with exchangeScopes and duplicate scopes are removed.

Applies to