Botframework-主动-未经授权的冷呼叫访问异常

Botframework-主动-未经授权的冷呼叫访问异常,botframework,Botframework,我有一个自定义WebApi控制器托管在我的普通bot messages控制器旁边。此自定义控制器经常接到呼叫,以便向用户执行主动消息传递以发送通知 public bool Post([FromBody]SchedulerTrigger triggerInfo) { try { //Initiate background processing of

我有一个自定义WebApi控制器托管在我的普通bot messages控制器旁边。此自定义控制器经常接到呼叫,以便向用户执行主动消息传递以发送通知

public bool Post([FromBody]SchedulerTrigger triggerInfo)
{
    try
    {                                                            
        //Initiate background processing of notifications
        Task.Run(() => NotificationTask.NotificationProcessing(triggerInfo));

    }
    catch (Exception ex)
    {

        throw ex;
    }

    return true;
}
控制器没有[BotAuthentication]属性,并且不应该有,因为它是从其他地方调用的

NotificationProcessing函数会进行一些处理,但最终会调用一个对话框:

public static async Task Resume(string resumptionCookie)
{
        //Deserialize reference to conversation
        ConversationReference conversationReference = JsonConvert.DeserializeObject<ConversationReference>(resumptionCookie);

        using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
        {
            var botData = scope.Resolve<IBotData>();

            await botData.LoadAsync(CancellationToken.None);

            //This is our dialog stack
            var task = scope.Resolve<IDialogTask>();

            //interrupt the stack. This means that we're stopping whatever conversation that is currently happening with the user
            //Then adding this stack to run and once it's finished, we will be back to the original conversation
            var dialog = new MyProActiveDialog();

            try
            {
                task.Call(dialog.Void<object, IMessageActivity>(), null);
                await task.PollAsync(CancellationToken.None);
            }
            catch (Exception ex)
            {
                //TODO
            }
            finally
            {
                //flush dialog stack
                await botData.FlushAsync(CancellationToken.None);
            }

        }
}
公共静态异步任务恢复(字符串恢复cookie)
{
//反序列化对会话的引用
ConversationReference ConversationReference=JsonConvert.DeserializeObject(resumptionCookie);
使用(var scope=DialogModule.BeginLifetimeScope(Conversation.Container,message))
{
var botData=scope.Resolve();
等待botData.LoadAsync(CancellationToken.None);
//这是我们的对话框堆栈
var task=scope.Resolve();
//中断堆栈。这意味着我们正在停止当前正在与用户进行的任何对话
//然后添加此堆栈以运行,一旦完成,我们将返回到原始对话
var dialog=new MyProActiveDialog();
尝试
{
task.Call(dialog.Void(),null);
wait task.PollAsync(CancellationToken.None);
}
捕获(例外情况除外)
{
//待办事项
}
最后
{
//刷新对话框堆栈
等待botData.FlushAsync(CancellationToken.None);
}
}
}
当Web服务启动并运行时,所有这些都可以正常工作,并且在microsoft bot和my webservice之间进行任何类型的聊天后,至少使用执行了一次登录

但是,如果我重新启动我的Web服务并启动主动讨论,我会得到UnauthorizedAccessException

我尝试使用BotAuthenticator执行手动身份验证,或使用传递的令牌添加[BotAuthentication],但我总是以UnauthorizedAccessException结束

所以我注意到啤酒商只在非冷启动时出现。我找不到在冷启动时强制验证的方法。。。


任何类型的帮助都将不胜感激。

我以前遇到过此错误。本质上,消息来自的通道是“可信的”。解决方法是信任该通道访问

尝试以下操作(第一个参数应为服务url):

MicrosoftAppCredentials.TrustServiceUrl(@"https://skype.botframework.com", DateTime.MaxValue);