Skip to content

Commit f43c3bc

Browse files
authored
Merge branch 'main' into users/rido/teams-samples
2 parents 8d2adca + e2b496f commit f43c3bc

File tree

1 file changed

+14
-1
lines changed
  • src/samples/Authorization/OBOAuthorization

1 file changed

+14
-1
lines changed

src/samples/Authorization/OBOAuthorization/Program.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,22 @@ CopilotClient GetClient(AgentApplication app, ITurnContext turnContext)
6060
"mcs");
6161
}
6262

63+
app.OnMessage("signout", async (turnContext, turnState, cancellationToken) =>
64+
{
65+
// Force a user signout to reset the user state
66+
// This is needed to reset the token in Azure Bot Services if needed.
67+
// Typically this wouldn't be need in a production Agent. Made available to assist it starting from scratch.
68+
await app.UserAuthorization.SignOutUserAsync(turnContext, turnState, cancellationToken: cancellationToken);
69+
await turnContext.SendActivityAsync("You have signed out", cancellationToken: cancellationToken);
70+
}, rank: RouteRank.First);
71+
6372
// Since Auto SignIn is enabled, by the time this is called the token is already available via UserAuthorization.GetTurnTokenAsync or
6473
// UserAuthorization.ExchangeTurnTokenAsync.
6574
// NOTE: This is a slightly unusual way to handle incoming Activities (but perfectly) valid. For this sample,
6675
// we just want to proxy messages to/from a Copilot Studio Agent.
6776
app.OnActivity((turnContext, cancellationToken) => Task.FromResult(true), async (turnContext, turnState, cancellationToken) =>
6877
{
78+
6979
var mcsConversationId = turnState.Conversation.GetValue<string>(MCSConversationPropertyName);
7080
var cpsClient = GetClient(app, turnContext);
7181

@@ -94,7 +104,10 @@ CopilotClient GetClient(AgentApplication app, ITurnContext turnContext)
94104
}
95105
}
96106
}
97-
});
107+
}, autoSignInHandlers: ["mcs"]);
108+
109+
110+
98111

99112
app.UserAuthorization.OnUserSignInFailure(async (turnContext, turnState, handlerName, response, initiatingActivity, cancellationToken) =>
100113
{

0 commit comments

Comments
 (0)