Share via


TeamsSSOTokenExchangeMiddleware Class

Definition

If the activity name is signin/tokenExchange, this middleware will attempt to exchange the token, and deduplicate the incoming call, ensuring only one exchange request is processed.

public class TeamsSSOTokenExchangeMiddleware : Microsoft.Bot.Builder.IMiddleware
type TeamsSSOTokenExchangeMiddleware = class
    interface IMiddleware
Public Class TeamsSSOTokenExchangeMiddleware
Implements IMiddleware
Inheritance
TeamsSSOTokenExchangeMiddleware
Implements

Remarks

If a user is signed into multiple Teams clients, the Bot could receive a "signin/tokenExchange" from each client. Each token exchange request for a specific user login will have an identical Activity.Value.Id.

Only one of these token exchange requests should be processed by the bot. The others return PreconditionFailed. For a distributed bot in production, this requires a distributed storage ensuring only one token exchange is processed. This middleware supports CosmosDb storage found in Microsoft.Bot.Builder.Azure, or MemoryStorage for local development. IStorage's ETag implementation for token exchange activity deduplication.

Constructors

TeamsSSOTokenExchangeMiddleware(IStorage, String)

Initializes a new instance of the TeamsSSOTokenExchangeMiddleware class.

Methods

OnTurnAsync(ITurnContext, NextDelegate, CancellationToken)

When implemented in middleware, processes an incoming activity.

Applies to