microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
f3962aa8cb149a3af8f27cd3d99e23640c843dce

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Samples/Samples.Auth/Program.cs

35lines · modecode

1using Microsoft.Teams.Apps;
2using Microsoft.Teams.Apps.Extensions;
3using Microsoft.Teams.Plugins.AspNetCore.Extensions;
4
5var builder = WebApplication.CreateBuilder(args);
6builder.AddTeams(App.Builder().AddLogger(level: Microsoft.Teams.Common.Logging.LogLevel.Debug));
7
8var app = builder.Build();
9var teams = app.UseTeams();
10
11teams.OnMessage("/signout", async context =>
12{
13 if (!context.IsSignedIn)
14 {
15 await context.Send("you are not signed in!");
16 return;
17 }
18
19 await context.SignOut();
20 await context.Send("you have been signed out!");
21});
22
23teams.OnMessage(async context =>
24{
25 if (!context.IsSignedIn)
26 {
27 await context.SignIn();
28 return;
29 }
30
31 var me = await context.UserGraph.Me.GetAsync();
32 await context.Send($"user '{me!.DisplayName}' is signed in!");
33});
34
35app.Run();