尝试验证时出现 403 Forbidden 错误

403 Forbidden Error when attempting to authenticate

我克隆了 运行 24.bot-authentication-msgraph to test authentication. I've updated the .bot file to put my app id and password as found https://apps.dev.microsoft.com。我还在 bot.js.

中更新了 CONNECTION_SETTING_NAME 变量

编辑:我 fork 了 repo,所以你可以看到我的代码和更改 here。检查最后 3 次提交以查看我的更改。我排除了我的 .bot 文件,因为它有我的应用程序密码。

但机器人甚至没有尝试对我进行身份验证,并且在控制台中,I received a 403 error。它没有描述或文字。

好吧,在进行了一些故障排除并故意破坏我的实现之后,我发现了问题所在。

你有两个"apps",1个"App Registration"在App Registration Portal and 1 "Web App Bot/Bot Channels Registration" in your Azure Resource Group (or at least you should if you follow the docs):

  1. this step 中创建的 Azure AD v1 或 v2 应用程序“创建 Azure AD v1/v2 应用程序
  2. this step 中创建的机器人频道注册应用程序“在 Azure 上创建您的机器人

根据您的图像,您在 .bot 文件中使用了 Azure AD v2 appId 和 appPassword,而您应该使用 Bot Channels Registration bot 的 appId 和 appPassword,如 [=15] 中所述=].

注意:Azure AD v2 appId和appPassword仅在editing your bot's Azure settings to add OAuth时使用。

您可以通过以下两种方式之一获取机器人的 appId 和 appPassword(您需要将其放入 .bot 文件中):

  • 通过应用程序注册门户
    1. 转到 App Registration Portal 并单击您的 机器人(不是 Azure AD v1/v2 应用程序)。
      • 如果您以类似的方式命名它们,如果它列出了 Web 平台,您就会知道您选择了错误的平台——它应该只在 Azure AD 中 v1/v2
    2. 它会列出你的appId,你可以 单击 "Generate New Password"
    3. 获取新密码

或者,

  • 通过 Azure 门户
    1. Azure 中打开您的资源组 传送门.
    2. 单击部署
    3. 在 "Deployment Name" 下,单击您的机器人频道注册机器人。
    4. 点击输入。你的appId和appPassword是APPID和APPSECRET, 分别。