简体   繁体   English

基于Bot模板(v4 SDK)的Bot的OAuth2登录不适用于MS Teams桌面应用

[英]OAuth2 Signin from a Bot, based on Enterprise Bot template(v4 SDK), does not work with MS Teams desktop app

I have a bot which is based on enterprise bot template(Bot builder framework SDK v4.0). 我有一个基于企业bot模板的机器人(Bot Builder框架SDK v4.0)。 I have called AuthenticationDialog (OAuth2 sign-in with AAD v2) as per other thread in the stack overflow, i have implemented to handle Invoke Activity with "signin/verifyState" in my IBot implementation , it works fine on Microsoft Teams Web app, however, MS Teams desktop app puts up the dialog for selecting sign-in user, immediately, it closes the dialog and sends the Invoke activity with signin/verifyState with "{ "state": "123456"} , i am displaying user to enter the state, when user enters, it works. Is it a bug in the Desktop MS Teams app (or) I am doing something wrong. 我已经按照堆栈溢出中的其他线程调用了AuthenticationDialog(使用AAD v2进行OAuth2登录),我已经实现了在IBot实现中使用“ signin / verifyState”来处理调用活动,它在Microsoft Teams Web应用程序上可以正常工作,但是,MS Teams桌面应用程序将打开用于选择登录用户的对话框,立即关闭对话框并使用“ {“ state”:“ 123456”}发送带有signin / verifyState的Invoke活动,我正在显示用户输入状态,当用户输入时,它可以正常工作。这是Desktop MS Teams应用程序中的错误吗?(或)我做错了什么。

From my bot, I don't use the following line which is in the SDK sample: 在我的机器人程序中,我不使用SDK示例中的以下行:

await Dialog.RunAsync(turnContext, conversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken)

In Slack same code works like this, bot puts up the sign-in dialog, when user clicks on Sign-In, browser display the sign-in option where user can select specific user name account, after successful login, it display the screen with: Please enter this validation code into the chat window to complete the sign-in: 123456 When user enters the code, automatically TokenResponse is given to the bot. 在Slack中,相同的代码是这样的,bot会打开登录对话框,当用户单击“登录”时,浏览器显示登录选项,用户可以在其中选择特定的用户名帐户,成功登录后,它会显示屏幕。 :请在聊天窗口中输入此验证代码以完成登录:123456当用户输入代码时,会自动将TokenResponse赋予机器人。

In TeamsAuth sample, Startup.cs calls // Create the bot as a transient. services.AddTransient<IBot, TeamsBot<MainDialog>>(); 在TeamsAuth示例中,Startup.cs调用// Create the bot as a transient. services.AddTransient<IBot, TeamsBot<MainDialog>>(); // Create the bot as a transient. services.AddTransient<IBot, TeamsBot<MainDialog>>(); In my bot calls services.AddBot<>() any idea how it can be done on my case? 在我的机器人中调用services.AddBot <>()知道如何在我的情况下完成它吗?

I have it working well with OAuthPrompt & Azure Bot Service in both Teams desktop and mobile. 我可以在Teams桌面版和移动版中将其与OAuthPrompt和Azure Bot Service配合使用。

Here is my code for your reference. 这是我的代码供您参考。 Check it out and see whether similar code works for you. 检查一下,看看是否类似的代码适合您。

BTW The new suggested way of adding bot is to register it using services.AddTransient<IBot, TBot>() . 顺便说一句,建议的添加bot的新方法是使用services.AddTransient<IBot, TBot>() Try to avoid using AddBot . 尝试避免使用AddBot

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Bot Builder SDK v4 中是否有企业机器人模板? - Will there be an Enterprise bot Template in Bot Builder SDK v4? 在 Visual Studio 2017 中加载机器人框架模板 - Loading bot framework template in Visual Studio 2017 为什么可变参数模板在模板引入中不起作用,而在需求子句中起作用? ConceptName {T,U,V,W} &lt;—模板 <typename …T> - Why does variadic template not work in template introduction but work in requires-clause? ConceptName{T,U,V,W} <— template<typename …T> 如何使用机器人创建和获取 Discord 服务器模板链接? - How to create and get Discord server template link using bot? Google bot击中我的应用程序时导致应用程序异常 - Google bot causing application exceptions when it hits my app 如何使MS Enterprise证书颁发机构实际使用自定义模板? - How do I make MS Enterprise Certificate Authority actually use a custom template? 为什么模板模板参数不能按预期工作? - Why does template template parameters not work as expected? template <typename> - 它是如何工作的? - template<typename> - how does it work? 设置模板不适用于首页 - Set template does not work for homepage extern模板不适用于gcc吗? - extern template does not work for gcc?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM