Azure active directory Microsoft Botframework V4虚拟助手Azure AD身份验证

Azure active directory Microsoft Botframework V4虚拟助手Azure AD身份验证,azure-active-directory,botframework,Azure Active Directory,Botframework,我已从GitHub下载、配置并部署了Microsoft Virtual Assistant开源项目,网址为: 我想从日历技能开始,并配置了所有内容。 当我请求当前日历条目时,botframework emulator中会显示身份验证提示,我可以使用Azure AD帐户进行身份验证 在那之后,是沉默 在CalendarSkill中的SummaryDialog.cs中,有一个类似于以下内容的WaterWallStep定义: var showSummary = new WaterfallSte

我已从GitHub下载、配置并部署了Microsoft Virtual Assistant开源项目,网址为:

我想从日历技能开始,并配置了所有内容。 当我请求当前日历条目时,botframework emulator中会显示身份验证提示,我可以使用Azure AD帐户进行身份验证

在那之后,是沉默

在CalendarSkill中的SummaryDialog.cs中,有一个类似于以下内容的WaterWallStep定义:

    var showSummary = new WaterfallStep[]
    {
        GetAuthToken,
        AfterGetAuthToken,
        ShowEventsSummary,
        CallReadEventDialog,
        AskForShowOverview,
        AfterAskForShowOverview
    };
执行步骤GetAuthToken,但随后停止执行。根本不调用AfterGetAuthToken

这是项目中的GetAuthToken函数:

protected async Task<DialogTurnResult> GetAuthToken(WaterfallStepContext sc, CancellationToken cancellationToken)
{
    try
    {
       var skillOptions = (CalendarSkillDialogOptions)sc.Options;

        // If in Skill mode we ask the calling Bot for the token
       if (skillOptions != null && skillOptions.SkillMode)
        {
            // We trigger a Token Request from the Parent Bot by sending a "TokenRequest" event back and then waiting for a "TokenResponse"
            // TODO Error handling - if we get a new activity that isn't an event
            var response = sc.Context.Activity.CreateReply();
            response.Type = ActivityTypes.Event;
            response.Name = "tokens/request";

            // Send the tokens/request Event
            await sc.Context.SendActivityAsync(response);

            // Wait for the tokens/response event
            return await sc.PromptAsync(SkillModeAuth, new PromptOptions());
        }
        else
        {
            return await sc.PromptAsync(nameof(MultiProviderAuthDialog), new PromptOptions());
        }
    }
    catch (SkillException ex)
    {
        await HandleDialogExceptions(sc, ex);
        return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
    }
    catch (Exception ex)
    {
        await HandleDialogExceptions(sc, ex);
        return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
    }
}
受保护的异步任务GetAuthToken(WaterCallStepContext sc,CancellationToken CancellationToken)
{
尝试
{
var skillOptions=(CalendarSkillDialogOptions)sc.Options;
//如果处于技能模式,我们向呼叫机器人请求令牌
if(skillOptions!=null&&skillOptions.SkillMode)
{
//我们通过发送“TokenRequest”事件并等待“TokenResponse”,从父机器人触发令牌请求
//TODO错误处理-如果我们得到一个不是事件的新活动
var response=sc.Context.Activity.CreateReply();
response.Type=ActivityTypes.Event;
response.Name=“令牌/请求”;
//发送令牌/请求事件
等待sc.Context.SendActivityAsync(响应);
//等待令牌/响应事件
return wait sc.PromptAsync(SkillModeAuth,new PromptOptions());
}
其他的
{
return wait sc.PromptAsync(nameof(MultiProviderAuthDialog),new PromptOptions());
}
}
捕获(SkillException ex)
{
等待处理异常(sc、ex);
返回新的DialogTurnResult(DialogTurnStatus.Cancelled,CommonUtil.DialogTurnResultCancellDialogs);
}
捕获(例外情况除外)
{
等待处理异常(sc、ex);
返回新的DialogTurnResult(DialogTurnStatus.Cancelled,CommonUtil.DialogTurnResultCancellDialogs);
}
}

我的代码是否有错误,或者配置中是否缺少任何内容?

我发现,如果电脑上没有配置ngrok,则虚拟助理无法工作。

嗨,Franz,您是否介意在appSettings中分享您是如何配置oauthConnections的?非常感谢。