python 机器人框架错误:未经授权的访问。请求未被授权

Error for python bot-framework: Unauthorized Access. Request is not authorized

我正在使用机器人框架与基于 python 的机器人合作。我正在使用样本 cookiecutter 回声模板。 Echo Bot

我已将机器人代码部署为 AWS lambda 函数,通过 API 网关连接。使用 NO APP 凭证的机器人模拟器测试成功。

当我尝试使用已注册的应用程序 ID 和应用程序密码对其进行测试时出现错误。我已经使用以下 url 注册了我的机器人: dev bot framework

我是否需要在我的机器人中添加任何额外的身份验证条款?如果有人能指出我正确的方向,那就太好了。谢谢!

这是错误回溯:

Traceback (most recent call last):
  File "C:\Users\abhishek.mishra\AppData\Local\Programs\Python\Python36\lib\site-packages\botbuilder\core\bot_framework_adapter.py", line 209, in process_activity
    await self.authenticate_request(activity, auth_header)
  File "C:\Users\abhishek.mishra\AppData\Local\Programs\Python\Python36\lib\site-packages\botbuilder\core\bot_framework_adapter.py", line 241, in authenticate_request
    self.settings.channel_service,
  File "C:\Users\abhishek.mishra\AppData\Local\Programs\Python\Python36\lib\site-packages\botframework\connector\auth\jwt_token_validation.py", line 42, in authenticate_request
    raise Exception("Unauthorized Access. Request is not authorized")
Exception: Unauthorized Access. Request is not authorized

我会自己回答这个问题,因为我能够解决这个错误。它确实带来了某些安全问题,但解决了无效访问问题。

根据文档 Bot Registration

In the section Supports account types, you must choose one of the 2 multi-tenant types that is: Accounts in any organizational directory (Any Azure AD - Multitenant) or Accounts in any organizational directory (Any Azure AD - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com), when creating the app, otherwise the bot will not work.

对应用程序注册进行此更改解决了错误并且服务运行正常。感谢所有尝试参与其中的人。