/// <summary> /// Sign a given user out of a previously linked account. /// </summary> /// <param name="userId">The user id value.</param> /// <param name="credentialProvider">The credential provider value.</param> /// <param name="connectionName">The connection name value.</param> /// <returns>Task.</returns> public async Task SignOutAsync(string userId, ICredentialProvider credentialProvider, string connectionName = null) { // The BotFramework Adapter, Bot ApplicationID and Bot Secret is required to access the Token APIs // These must match the Bot making use of the Linked Accounts feature. var adapter = new BotFrameworkAdapter(credentialProvider); var botAppId = ((ConfigurationCredentialProvider)credentialProvider).AppId; var botAppPassword = ((ConfigurationCredentialProvider)credentialProvider).Password; using (var context = new TurnContext(adapter, new Microsoft.Bot.Schema.Activity { })) { var connectorClient = new ConnectorClient(new Uri(TokenServiceUrl), botAppId, botAppPassword); context.TurnState.Add <IConnectorClient>(connectorClient); // Sign the specified user out of a particular connection await adapter.SignOutUserAsync(context, connectionName, userId); } }