【发布时间】:2019-01-14 07:42:34
【问题描述】:
我在 Azure 中有一个带有 AppId 和 AppPass 的 Bot Channels Registration
我已从 Visual Studio 将 Bot 部署到 App Service 并添加 MicrosoftAppId 和 MicrosoftAppPassword
使用电报客户端我有同样的错误 POST 到 xxx 失败:POST 到机器人的端点失败,HTTP 状态为 403
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddBot<IAssistantBot>(options =>
{
var secretKey = Configuration.GetSection("botFileSecret")?.Value;
// Loads .bot configuration file and adds a singleton that your Bot can access through dependency injection.
var botConfig = BotConfiguration.Load(@".\IAssistant.Bot.bot", secretKey);
services.AddSingleton(sp => botConfig);
// Retrieve current endpoint.
var service = botConfig.Services.Where(s => s.Type == "endpoint" && s.Name == "development").FirstOrDefault();
if (!(service is EndpointService endpointService))
{
throw new InvalidOperationException($"The .bot file does not contain a development endpoint.");
}
options.CredentialProvider = new SimpleCredentialProvider(endpointService.AppId, endpointService.AppPassword);
// Catches any errors that occur during a conversation turn and logs them.
options.OnTurnError = async (context, exception) =>
{
await context.SendActivityAsync("Sorry, it looks like something went wrong.");
};
});
}
什么原因?
【问题讨论】:
-
.NET 还是 Node?你能分享你的初始化逻辑吗?需要看看你是如何配置凭据的。
-
@DrewMarsh 感谢您的回答。我已经添加了一个有问题的细节。项目是 .NET Core 2.1
-
@DrewMarsh 感谢您的提示。错误出现在“当前端点”
-
所以你明白了吗?只需为您的生产端点配置正确的凭据即可?
-
@DrewMarsh 在制作中我使用了具有错误凭据的开发端点
标签: configuration botframework credentials