IChannelServiceClientFactory.CreateConnectorClientAsync Method

Definition

Overloads

CreateConnectorClientAsync(ITurnContext, String, IList<String>, Boolean, CancellationToken)

Creates an instance of a IConnectorClient for the turn.

public System.Threading.Tasks.Task<Microsoft.Agents.Connector.IConnectorClient> CreateConnectorClientAsync(Microsoft.Agents.Builder.ITurnContext turnContext, string audience = default, System.Collections.Generic.IList<string> scopes = default, bool useAnonymous = false, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateConnectorClientAsync : Microsoft.Agents.Builder.ITurnContext * string * System.Collections.Generic.IList<string> * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Agents.Connector.IConnectorClient>
Public Function CreateConnectorClientAsync (turnContext As ITurnContext, Optional audience As String = Nothing, Optional scopes As IList(Of String) = Nothing, Optional useAnonymous As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IConnectorClient)

Parameters

turnContext
ITurnContext

The context for the current turn, providing access to conversation and user information. Cannot be null.

audience
String

An optional audience identifier for which the connector client is created. If null, the default audience is used.

scopes
IList<String>

An optional list of scopes that specify the permissions granted to the connector client. If null, default scopes are applied.

useAnonymous
Boolean

A value indicating whether to create the connector client using anonymous authentication. If true, the client is created without user credentials.

cancellationToken
CancellationToken

A cancellation token that can be used to cancel the asynchronous operation.

Returns

A task that represents the asynchronous operation. The task result contains an instance of IConnectorClient for interacting with the specified audience and scopes.

Remarks

This normally wouldn't be called directly by an Agent developer, but rather is used internally by a IChannelAdapter to create the client needed to communicate back to the sender. This is called at the beginning of each turn. The Agent developer can get a turn appropriate IConnectorClient by calling turnContext.Services.Get<IConnectorClient>().

Applies to

CreateConnectorClientAsync(ClaimsIdentity, String, String, CancellationToken, IList<String>, Boolean)

Caution

This method is deprecated. Please use CreateConnectorClientAsync(ITurnContext, string, IList<string>, bool, CancellationToken) instead.

Creates a IConnectorClient that can be used to create IConnectorClient.

[System.Obsolete("This method is deprecated. Please use CreateConnectorClientAsync(ITurnContext, string, IList<string>, bool, CancellationToken) instead.")]
public System.Threading.Tasks.Task<Microsoft.Agents.Connector.IConnectorClient> CreateConnectorClientAsync(System.Security.Claims.ClaimsIdentity claimsIdentity, string serviceUrl, string audience, System.Threading.CancellationToken cancellationToken, System.Collections.Generic.IList<string> scopes = default, bool useAnonymous = false);
[<System.Obsolete("This method is deprecated. Please use CreateConnectorClientAsync(ITurnContext, string, IList<string>, bool, CancellationToken) instead.")>]
abstract member CreateConnectorClientAsync : System.Security.Claims.ClaimsIdentity * string * string * System.Threading.CancellationToken * System.Collections.Generic.IList<string> * bool -> System.Threading.Tasks.Task<Microsoft.Agents.Connector.IConnectorClient>
Public Function CreateConnectorClientAsync (claimsIdentity As ClaimsIdentity, serviceUrl As String, audience As String, cancellationToken As CancellationToken, Optional scopes As IList(Of String) = Nothing, Optional useAnonymous As Boolean = false) As Task(Of IConnectorClient)

Parameters

claimsIdentity
ClaimsIdentity

The inbound Activity's ClaimsIdentity.

serviceUrl
String

The service URL.

audience
String

An optional audience identifier for which the connector client is created. If null, the default audience is used.

cancellationToken
CancellationToken

A cancellation token.

scopes
IList<String>

The scopes to request.

useAnonymous
Boolean

Whether to use anonymous credentials.

Returns

A IConnectorClient.

Attributes

Remarks

This is called at the beginning of each turn.

Applies to