2

With the following Url I found a way how to extract the secret keys of a webchat bot:

https://dev.botframework.com/api/bots/{bot_id}/channels/webchat"

It will return a JSON response like following: webchat secret keys

This works well when I call it in a browser and when I am logged in on https://dev.botframework.com/. Now I would like to script it with powershell. Before starting to script it, I tried to call it with Postman. My problem is that I need a token (access token?) to call it with Postman. If I grab the IntercomAuthCookie from my browser session into the headers in Postman, I get the expected result, like here.

Now my question is: with which API can I get the IntercomAuthCookie?

I tried to get a Bearer access token here with OAuth on https://login.microsoftonline.com/common/oauth2/v2.0/token, but when I use it on the other request I get a "login expired"

4

1 回答 1

2

经过数周和大量搜索,我找到了三种获取 WebChat 频道密钥的方法。


Dev Botframework 浏览器方法

您可以使用以下 URL 以 JSON 格式获取它:

https://dev.botframework.com/identity/signin?requestUrl=/api/bots/{botId}/channels/webchat

它会询问您的凭据并将您重定向到 https://dev.botframework.com/api/bots/{botId}/channels/webchat。


Azure Cli 方法(不推荐)

在这篇文章的帮助下,如何以编程方式获取 Microsoft Bot Framework 聊天机器人应用程序的 DirectLine 机密?,我找到了以下命令:

az bot webchat show -n "{botId}" -g "{resourceGroupName}" --with-secrets --subscription "{subscriptionId}"

在运行上述命令之前不要忘记登录(使用“az login”命令)。

为什么不推荐这种方法?
我意识到在运行此命令后,它破坏了 Azure 中的 WebChat 通道,我无法将其重新恢复工作。这就是为什么我强烈不建议使用它。


HTTP GET 请求方法 - 无需浏览器(最推荐用于脚本编写)

在对 Python Azure Cli Bot Service 和 Azure Mgmt Bot Service 源代码进行了大量研究之后,我发现了以下请求:

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BotService/botServices/{botId}/channels/WebChatChannel/listChannelWithKeys ?api-version= 2018-07-12

不要忘记将访问承载令牌添加到请求的授权密钥标头中。


我测试了所有方法。一切都按预期工作。

于 2019-01-05T00:16:58.500 回答