MS ChatBot - ClientConnector未经授权的异常

问题描述 投票:3回答:1

我正在尝试使用ConnectorClient从Azure函数发送主动消息,但我获得了授权异常,尽管使用了正确的AppIdAppPassword

var connector = new ConnectorClient(new Uri(queueMessage.ChatBotDetails.ServiceUrl), new MicrosoftAppCredentials(appId, appPassword));

await connector.Conversations.SendToConversationAsync((Activity)message);

但这会产生以下异常:

Microsoft.Bot.Connector.ErrorResponseException: Operation returned an invalid status code 'Unauthorized'

我在日志中输出应用密码和应用ID,它们是正确的。

azure botframework chatbot
1个回答
5
投票

结果我只需要在调用连接器客户端之前添加此调用:

MicrosoftAppCredentials.TrustServiceUrl(queueMessage.ChatBotDetails.ServiceUrl);

© www.soinside.com 2019 - 2024. All rights reserved.