Using MS Teams as Channel: Authentification Dialog (GetTokenDialog class from Microsoft.Bot.Builder.Dialogs) doesn't popup

巧了我就是萌 提交于 2019-12-25 00:16:44

问题


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?


回答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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/50828452/using-ms-teams-as-channel-authentification-dialog-gettokendialog-class-from-mi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!