问题
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.
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)
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.
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?
回答1:
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 The new suggested way of adding bot is to register it using services.AddTransient<IBot, TBot>(). Try to avoid using AddBot.
来源:https://stackoverflow.com/questions/57663234/oauth2-signin-from-a-bot-based-on-enterprise-bot-templatev4-sdk-does-not-wor