基于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

查看:116
本文介绍了基于Bot模板(v4 SDK)的Bot的OAuth2登录不适用于MS Teams桌面应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于企业bot模板的机器人(Bot Builder框架SDK v4.0).我已经按照堆栈溢出中的其他线程调用了AuthenticationDialog(使用AAD v2进行OAuth2登录),我已经实现了在IBot实现中使用"signin/verifyState"来处理调用活动,它在Microsoft Teams Web应用程序上可以正常工作,但是,MS Teams桌面应用程序会打开用于选择登录用户的对话框,立即关闭对话框并发送带有signin/verifyState和"{"state":"123456"}的Invoke活动,我正在显示用户输入状态,当用户进入时,它可以工作.这是Desktop MS Teams应用程序中的错误吗?(或)我做错了什么.

I have a bot which is based on enterprise bot template(Bot builder framework 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.

在我的漫游器中,我没有使用SDK示例中的以下行:

From my bot, I don't use the following line which is in the SDK sample:

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

在Slack中,相同的代码是这样的,bot会打开登录对话框,当用户单击登录"时,浏览器显示登录选项,用户可以在其中选择特定的用户名帐户,成功登录后,它将显示屏幕上显示:请在聊天窗口中输入以下验证码以完成登录:123456当用户输入代码时,会自动将TokenResponse赋予机器人.

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.

在TeamsAuth示例中,Startup.cs调用//将漫游器创建为瞬态.services.AddTransient< IBot,TeamsBot< MainDialog>>(); 在我的机器人通话中services.AddBot<>()知道如何针对我的案子吗?

In TeamsAuth sample, Startup.cs calls // 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?

推荐答案

我可以将其与OAuthPrompt&Teams桌面版和移动版中的Azure Bot服务.

I have it working well with OAuthPrompt & Azure Bot Service in both Teams desktop and mobile.

这是我的代码供您参考.检查一下,看看类似的代码是否对您有用.

Here is my code for your reference. Check it out and see whether similar code works for you.

BTW建议的添加bot的新方法是使用 services.AddTransient< IBot,TBot>()注册它.尝试避免使用 AddBot .

BTW The new suggested way of adding bot is to register it using services.AddTransient<IBot, TBot>(). Try to avoid using AddBot.

这篇关于基于Bot模板(v4 SDK)的Bot的OAuth2登录不适用于MS Teams桌面应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆