Bot Framework无法通过Enterprise Bot进行身份验证

时间:2019-03-11 21:37:36

标签: c# botframework

我当前正在使用Enterprise Bot模板,但无法完成身份验证对话框。每次我尝试调用它时,它都会返回到令牌发布,然后停止执行。不会在瀑布中进一步击中getToken方法(即,我可以登录并获得魔术代码,但是当我将其粘贴到模拟器中以继续进行身份验证时,对话框将停止)。

我已经尝试了来自github的AuthenticationBot示例,并且工作正常。我认为这与routerDialog和/或OnTurnAsync方法有关,但我不知道它可能是什么。 编辑:

AddDialog(new WaterfallDialog(InitialDialogId, authenticate));
AddDialog(new OAuthPrompt(DialogIds.LoginPrompt, new OAuthPromptSettings()
            {
                ConnectionName = ConnectionName,
                Title = AuthenticationStrings.TITLE,
                Text = AuthenticationStrings.PROMPT,
            }));
private async Task<DialogTurnResult> PromptToLogin(WaterfallStepContext sc, CancellationToken cancellationToken)
        {
            return await sc.PromptAsync(AuthenticationResponses.ResponseIds.LoginPrompt, new PromptOptions());
        }
var dc = await _dialogs.CreateContextAsync(turnContext);

    if (dc.ActiveDialog != null)
    {
        var result = await dc.ContinueDialogAsync();
        if (!turnContext.Responded)
        {
             // Start the Login process.
             await dc.ContinueDialogAsync();
        }
    }
    else
    {
        await dc.BeginDialogAsync(nameof(MainDialog));
    }

这是有关将活动发送到哪里的身份验证的两个代码块。

编辑2 /解决方案: 只是想跟进,我才弄清楚我所缺少的。在bot.cs主文件的OnTurnAsync中,我需要在构造函数中添加这段代码和一段代码。 构造函数

_dialogs.Add(new AuthenticationDialog(_services.AuthConnectionName));

OnTurnAsync

if (!turnContext.Responded)
{
    await dc.BeginDialogAsync(nameof(AuthenticationDialog));
}

0 个答案:

没有答案