来自网络聊天的未经授权的Bot服务 [英] Unauthorized Bot Service from Web Chat

查看:90
本文介绍了来自网络聊天的未经授权的Bot服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Microsoft Bot Framework,我创建了一个聊天Bot,并且能够使用本地仿真器测试Bot. Bot服务还可以处理LUIS,并且一切正常.我的Bot服务在web.config中具有MicrosoftAppIdMicrosoftAppPassword.

Using Microsoft Bot Framework, I created a Chat Bot and I am able to test the Bot using local Emulator. Bot service also deals with LUIS and everything again works just fine. My Bot Service has MicrosoftAppId and MicrosoftAppPassword in web.config.

我将服务部署到了Azure.然后将网络聊天嵌入到浏览器中( Github ),但是它不起作用.错误说

I deployed the service to Azure. Then embedded a web chat in browser (Github) but it doesn't work. The error say

Buffer="{
  "message": "An error has occurred.",
  "exceptionMessage": "Unauthorized",
  "exceptionType": "Microsoft.Bot.Connector.MicrosoftAppCredentials+OAuthException",
  "stackTrace": "   at Microsoft.Bot.Sample.LuisBot.MessagesController.<Post>d__0.MoveNext()

......

    "innerException": {
        "message": "An error has occurred.",
        "exceptionMessage": "Response status code does not indicate success: 401 (Unauthorized).",
        "exceptionType": "System.Net.Http.HttpRequestException",
        "stackTrace": "   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\r\n   at Microsoft.Bot.Connector.MicrosoftAppCredentials.<RefreshTokenAsync>d__26.MoveNext()"

我相信当我传递Web聊天秘密密钥(我也尝试传递生成的令牌但没有运气)时,应该自动对其进行授权(传递App IdPassword).不是吗?

I believe when I pass my Web Chat Secret Key (I have also tried to pass generated Token but no luck), then it should be authorized (passing App Id and Password) automatically. Is it not?

  1. 浏览器嵌入式Web聊天显示未经授权的错误.
  2. 在Web聊天窗口中进行测试会给出相同的错误.

我还尝试通过删除MicrosoftAppIdMicrosoftAppPassword来部署Bot服务,但没有任何变化.

I have also tried to deploy Bot service by removing MicrosoftAppId and MicrosoftAppPassword but nothing changes.

对我来说,这都是很新的.有人可以帮我弄清楚这个问题吗?公开赠送我的Microsoft App ID也可以吗?

Its all very new to me. Could someone please help me to get some clarity on this issue? Also is it fine to give away my Microsoft App Id publicly?

编辑1

在浏览器中实现Web聊天控件.

Implementation of Web Chat control in Browser.

  1. 创建了ASP.Net空网站,并有一个HTML页面(index.html).
  2. 以下代码写在index.html页面中.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>

    <div id="bot" />
    <hr />

    <iframe width="400" height="300" src='https://webchat.botframework.com/embed/#Web_App_Bot_Name#?s=Web_Chat_Secret_Key'></iframe>
</body>
</html>

  1. Microsoft App ID = f0f7297e-7a95-4a8f-afc1-eb3d19906cd0
  2. 通过我的代码呈现的屏幕如下所示.当我发送消息时,提示无法发送".在App Service的Azure Diagnostics中,我看到错误为未经授权".
  1. Microsoft App Id = f0f7297e-7a95-4a8f-afc1-eb3d19906cd0
  2. Screen rendered via my code looks like this. And when I send message, it says Couldn't Send. In Azure Diagnostics for App Service, I see error as Unauthorized.

推荐答案

401(未经授权)

401 (Unauthorized)

您可以尝试执行以下步骤来解决此问题:

You can try the following steps to troubleshoot the issue:

  1. 请检查您是否在应用程序设置刀片上为机器人指定了正确的MicrosoftAppIDMicrosoftAppPassword.

  1. Please check if you specify the correct MicrosoftAppID and MicrosoftAppPassword for your bot on Application Settings blade.

请检查是否在

Please check if you specify the correct message endpoint for the bot on the Settings blade.

注意 :您也可以尝试管理您的MicrosoftApp并为此生成新密码应用程序,然后在应用程序设置"边栏选项卡上使用新生成的密码指定MicrosoftAppPassword,并检查它是否可以使用新密码.

Note: You can also try to Manage your MicrosoftApp and Generate New Password for that app, and specify MicrosoftAppPassword with new generated password on Application Settings blade and check if it works with new password.

请尝试在Azure门户上创建一个新的bot,并将您的bot应用程序发布到您指定为消息传递终结点的相应Web应用程序,然后检查该新的bot是否工作正常.

Please try to create a new bot on Azure portal, and publish your bot application to corresponding web application that you specified as messaging endpoint, and check if that new bot works fine.

此外,如果即使您设置了正确的配置,它仍然无法按预期工作,则可以尝试

Besides, if it still does not work as expected even if you set correct configuration, you can try to create support request to report it.

这篇关于来自网络聊天的未经授权的Bot服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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