Table of Contents

Class RestChannelServiceClientFactory

Namespace
Microsoft.Agents.Builder
Assembly
Microsoft.Agents.Builder.dll

A factory to create REST clients to interact with a Channel Service.

public class RestChannelServiceClientFactory : IChannelServiceClientFactory
Inheritance
RestChannelServiceClientFactory
Implements
Inherited Members

Remarks

Connector and UserToken client factory.

Constructors

RestChannelServiceClientFactory(IConfiguration, IHttpClientFactory, IConnections, string, string, ILogger)

public RestChannelServiceClientFactory(IConfiguration configuration, IHttpClientFactory httpClientFactory, IConnections connections, string tokenServiceEndpoint = "https://api.botframework.com", string tokenServiceAudience = "https://api.botframework.com", ILogger logger = null)

Parameters

configuration IConfiguration
httpClientFactory IHttpClientFactory

Used to create an HttpClient with the fullname of this class

connections IConnections
tokenServiceEndpoint string
tokenServiceAudience string
logger ILogger

Exceptions

ArgumentNullException
ArgumentException
InvalidOperationException

Thrown when an instance of Microsoft.Agents.Authentication.IAccessTokenProvider is not found via Microsoft.Agents.Authentication.IConnections.

Methods

CreateConnectorClientAsync(ClaimsIdentity, string, string, CancellationToken, IList<string>, bool)

Creates a Microsoft.Agents.Connector.IConnectorClient that can be used to create Microsoft.Agents.Connector.IConnectorClient.

public Task<IConnectorClient> CreateConnectorClientAsync(ClaimsIdentity claimsIdentity, string serviceUrl, string audience, CancellationToken cancellationToken, IList<string> scopes = null, bool useAnonymous = false)

Parameters

claimsIdentity ClaimsIdentity

The inbound Activity's ClaimsIdentity.

serviceUrl string

The service URL.

audience string
cancellationToken CancellationToken

A cancellation token.

scopes IList<string>

The scopes to request.

useAnonymous bool

Whether to use anonymous credentials.

Returns

Task<IConnectorClient>

A Microsoft.Agents.Connector.IConnectorClient.

Remarks

This is called at the beginning of each turn.

Exceptions

ArgumentNullException
ArgumentException
InvalidOperationException

Thrown when an instance of Microsoft.Agents.Authentication.IAccessTokenProvider is not found via Microsoft.Agents.Authentication.IConnections.

CreateUserTokenClientAsync(ClaimsIdentity, CancellationToken, bool)

Creates the appropriate Microsoft.Agents.Connector.IUserTokenClient instance.

public Task<IUserTokenClient> CreateUserTokenClientAsync(ClaimsIdentity claimsIdentity, CancellationToken cancellationToken, bool useAnonymous = false)

Parameters

claimsIdentity ClaimsIdentity

The inbound Activity's ClaimsIdentity.

cancellationToken CancellationToken

A cancellation token.

useAnonymous bool

Whether to use anonymous credentials.

Returns

Task<IUserTokenClient>

Asynchronous Task with Microsoft.Agents.Connector.IUserTokenClient instance.

Exceptions

ArgumentNullException
ArgumentException
InvalidOperationException

Thrown when an instance of Microsoft.Agents.Authentication.IAccessTokenProvider is not found via Microsoft.Agents.Authentication.IConnections.