admin管理员组文章数量:1287964
I have a back-end flask server currently running locally and made available to azure using ngrok. I want to connect this back-end the Azure bot service. The back-end receives messages from the "Test in Web Chat" but get a 401 when I send the response. As far as I can figure I need to give the API the correct permissions.
It is a single tenant bot.
Code to generate the token for the response
url = "/oauth2/v2.0/token"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret,
"scope": "/.default"
}
The decoded token
{
"typ": "JWT",
"alg": "RS256",
"x5t": "imi0Y2z0dYKxBttAqK_Tt5hYBTk",
"kid": "imi0Y2z0dYKxBttAqK_Tt5hYBTk"
}.{
"aud": ";,
"iss": "/",
"iat": 1740236233,
"nbf": 1740236233,
"exp": 1740322933,
"aio": "k2RgYGC/rfLecEbpExbj5edObn+xAAA=",
"appid": "59db3818-3845-4cd7-93ef-0ec3efff7974",
"appidacr": "1",
"idp": "/",
"idtyp": "app",
"rh": "1.AW4AIJTU1pvz902h3NWak1hx20IzLY0pz1lJlXcODq-9FrxeAQBuAA.",
"tid": "d6d49420-f39b-4df7-a1dc-d59a935871db",
"uti": "-m34WPWqiUSVGPdqi39PAA",
"ver": "1.0",
"xms_idrel": "13 32"
}.[Signature]
Code for sending the response back to Azure bot.
url = f"/{conversation_id}/activities"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
json_block= {
"type": "message",
"text": "Hello from the bot!"
}
try:
response = requests.post(url, headers=headers, json=json_block)
The error I get is '{"message":"Authorization has been denied for this request."}'
Here is the list of API permissions I gave my project in Microsoft Graph.
Permission | Type | Description |
---|---|---|
APIConnectors.Read.All | Delegated | Read API connectors for authentication flows |
APIConnectors.ReadWrite.All | Delegated | Read and write API connectors for authentication flows |
ChannelMessage.Read.All | Application | Read all channel messages |
Chat.Create | Delegated | Create chats |
Chat.ManageDeletion.All | Delegated | Delete and recover deleted chats |
Chat.Read | Delegated | Read user chat messages |
Chat.ReadBasic | Delegated | Read names and members of user chat threads |
Chat.ReadWrite | Delegated | Read and write user chat messages |
Chat.ReadWrite.All | Delegated | Read and write all chat messages |
Chat.ReadWrite.All | Application | Read and write all chat messages |
ChatMessage.Read | Delegated | Read user chat messages |
ChatMessage.Send | Delegated | Send user chat messages |
User.Read.All | Application | Read all users' full profiles |
本文标签: chatbotWhat are Azure permissions for Azure Bot Service when using a RestAPIStack Overflow
版权声明:本文标题:chatbot - What are Azure permissions for Azure Bot Service when using a RestAPI? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741330336a2372732.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论