0

How can I use the new authentification feature in Bot Builder with MS Teams?

There seems to be an issue with Teams (see Login user with MS Teams bot or https://github.com/Microsoft/BotBuilder/issues/2104), seems if this is not considered in GetTokenDialog?

Is there any chance to get around this?

Ilona Tag
  • 31
  • 4
  • 1
    You are referring to old tickets (beginning of 2017) that are closed (with a solution). Can you add more details of your problem and add some code to show where is this problem? – Nicolas R Jun 14 '18 at 08:19
  • The Problem is: In Teams, nothing happens when you click on the signin button which is meant to popup the authentification dialog. On code side, this is just a call of GetTokenDialog: private GetTokenDialog CreateGetTokenDialog() { return new GetTokenDialog( ConnectionName, $"Please authentifiy for {ConnectionName}.", "Login", 2, "That didn't work - Try again!"); } - so I guess the problem must be fixed in the code of that function – Ilona Tag Jun 15 '18 at 03:12
  • Adding a code sample of the problem may help getting a response – Nicolas R Jun 15 '18 at 07:46
  • The call of GetTokenDialog (a function which is provided in Microsoft.Bot.Builder.Dialogs) does not work when using MS Teams as a channel - to be concrete, a click on the displayed "Login" button doesn't popup the seperate authentification dialog as it does when using the local emulator: `private GetTokenDialog CreateGetTokenDialog() { return new GetTokenDialog( ConnectionName, $"Please signin for {ConnectionName}.", "Login", 2, "Try again!"); }` – Ilona Tag Jun 16 '18 at 03:47

3 Answers3

1

Just found the reason why it won't work with Teams. In method Microsoft.Bot.Connector.Activity.CreateOAuthReplyAsync(), Parameter asSignInCard has to be set to True for MSTeams, then, the line new CardAction() { Title = buttonLabel, Value = link, Type = ActionTypes.Signin } has to be changed to new CardAction() { Title = buttonLabel, Value = link, Type = ActionTypes.OpenUrl } because MS Teams can obviously not deal with Action type Signin. Hope, the MS developers will fix that method soon.

Ilona Tag
  • 31
  • 4
  • Where do you add or use new CardAction? I am just using CreateOAuthReplyAsync. In the Emulator this works. As mentioned in the initial question for Teams it doesn't. If you could kindly let me know where to use the CardAction. Thank you. – Franz Kiermaier Sep 13 '18 at 13:05
1

There are a few things you need to do to get this to work. First you need to create a manifest file for your bot in teams and whitelist token.botframework.com. That is the first problem.

From teams itself in AppStudio you create a Manifest. I had to play around with this a little bit. In AppDetails... Let it generate a new ID. Just hit the button. The URLs really don't matter much for testing. The package name just needs to be unique so something like com.ilonatag.teams.test

In the bots section you plug in your MS AppId and a bot name. This is a the real MSAPPID from your bots MicrosoftAppId" value=" from web.config in your code.

Ok now in "finish->valid domains" I added token.botframework.com and also the URL for my bot just in case. so something like franktest.azurewebsites.net

This part is done but you are not quite done... in your messages controller you need to add this since Teams sends a different verification than the other clients.

if (message.Type == ActivityTypes.Invoke)
{
                // Send teams Invoke along to the Dialog stack
                if (message.IsTeamsVerificationInvoke())
                {
                    await Conversation.SendAsync(message, () => new Dialogs.RootDialog());
                }
}

It took me a bunch of going back and forth with Microsoft to get this sorted out.

FrankPrime
  • 11
  • 1
0

This is a known problem using OAuthCard in MS Teams. To solve it, you can change the Button ActionType from signIn to openUrl using this solution on github

desflan
  • 468
  • 3
  • 13