简体   繁体   English

MS Teams 消息扩展在测试服务器上不起作用[云]

[英]MS Teams Message Extension not working on test server[Cloud]

I have developed MS Teams Message Extension using Java[Spring Boot] and registered the bot in Botframework Development portal[https://dev.botframework.com/].我已经使用 Java [Spring Boot] 开发了 MS Teams 消息扩展,并在 Botframework 开发门户 [https://dev.botframework.com/] 中注册了该机器人。 It is working fine in local.它在本地运行良好。 I tested in local environment using a tunneling application named localtunnel.我使用名为 localtunnel 的隧道应用程序在本地环境中进行了测试。 I tested the extension in MS Teams.我在 MS Teams 中测试了扩展。

I pushed the code to cloud[AWS] as it was working fine on local and also changed the message endpoint URL to point to our test server.我将代码推送到云 [AWS],因为它在本地运行良好,并且还更改了消息端点 URL 以指向我们的测试服务器。 But, unfortunately i am getting " Bot returned unsuccessful status code unauthorized."[You can see the screenshot].但是,不幸的是我得到“机器人返回不成功的状态码未经授权。”[你可以看到截图]。 Test server message endpoint doesn't require JWT token, I am able to call it successfully from postman with out giving token.测试服务器消息端点不需要 JWT 令牌,我可以从邮递员那里成功调用它而无需提供令牌。

As per the documentation, this error occurs usually when:根据文档,此错误通常发生在以下情况:

  • The Messaging endpoint specified on the Settings page for your bot in the Bot Framework Portal is incorrect.在 Bot Framework Portal 中您的机器人的设置页面上指定的消息传递端点不正确。 Make sure you have included the proper path at the end of the URL (eg, /api/messages).确保在 URL 的末尾包含正确的路径(例如,/api/messages)。

  • The Messaging endpoint specified on the Settings page for your bot in the Bot Framework Portal does not begin with https or is not trusted by the Bot Framework.在 Bot Framework 门户中为您的 bot 的设置页面上指定的消息传递端点不以 https 开头,或者不受 Bot Framework 信任。 Your bot must have a valid, chain-trusted certificate.您的机器人必须具有有效的链式信任证书。

  • The bot is configured with missing or incorrect values for app ID or password.机器人配置了应用 ID 或密码的缺失值或错误值。 Verify that the bot configuration settings specify valid values for app ID and password.验证机器人配置设置是否为应用 ID 和密码指定了有效值。

All the points are correct in my case.在我的情况下,所有观点都是正确的。

In this documentation, It is mentioned about Azure Bot resources in the "Test your bot" section of "Step 4: Test your bot in the cloud".在本文档中,“步骤 4:在云中测试你的机器人”的“测试你的机器人”部分提到了 Azure 机器人资源。

https://docs.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0&tabs=csharp#step-3 https://docs.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0&tabs=csharp#step-3

So in order to test the bot on cloud, is it necessary to register it on Azure Bot services instead of Botframework development portal?那么为了在云上测试机器人,是否需要在 Azure Bot 服务而不是 Botframework 开发门户上进行注册呢? Can't we just test it just by registering it on Botframework development portal?我们不能只通过在 Botframework 开发门户上注册来测试它吗?

在此处输入图像描述

The dev.botframework.com portal is deprecated, so I'd advise against continuing to use it. dev.botframework.com门户已弃用,因此我建议不要继续使用它。 The Azure Bot resource is the evolution and replacement of the Bot Channels Registration, so you will need to use it to test your bot in the cloud. Azure Bot 资源是 Bot Channels Registration 的演变和替代,因此您需要使用它在云中测试您的 bot。 It effectively does the same things, but it better handles various new security and tenancy features that the old portal did not.它有效地做同样的事情,但它更好地处理旧门户没有的各种新的安全和租赁功能。

Furthermore, the documentation you linked mentions that extra security configuration steps must be taken for non-Azure deployments to get your bot to use https.此外,您链接的文档提到必须为非 Azure 部署采取额外的安全配置步骤,以使您的机器人使用 https。 Ensure you do this before filling in the messaging endpoint in your Azure Bot configuration.确保在填写 Azure Bot 配置中的消息传递终结点之前执行此操作。

I figure out the issue.我弄清楚了这个问题。 Even though message endpoint could be called without any JWT token of our app, code was verifying the token if in case it is present in Authorization header instead of ignoring it.尽管可以在没有我们应用程序的任何 JWT 令牌的情况下调用消息端点,但如果令牌出现在 Authorization 标头中而不是忽略它,代码会验证令牌。 MS Teams sends JWT token in Authorization header of every request to verify it is coming from teams, but extension app was comparing this token sent from teams against our app. MS Teams 在每个请求的 Authorization 标头中发送 JWT 令牌以验证它是否来自团队,但扩展应用程序正在将团队发送的此令牌与我们的应用程序进行比较。 Since this token is not created by our app but instead by bot framework, so it was throwing 401 unauthorized.由于这个令牌不是由我们的应用程序创建的,而是由 bot 框架创建的,所以它在未经授权的情况下抛出 401。

So make sure your app is in ignoring the token sent in Authorization header for message endpoint.因此,请确保您的应用忽略在消息端点的授权标头中发送的令牌。

About the other doubts I had:关于我的其他疑问:

  • It is not mandatory to register bot in azure in order to test in cloud, you can register it in development portal as well.在 azure 中注册 bot 以便在云中进行测试不是强制性的,您也可以在开发门户中注册它。 Since development portal is depreciated, I highly recommend to use azure as it is highly secure.由于开发门户已贬值,我强烈建议使用 azure,因为它非常安全。

  • You can do non azure deployment as well.您也可以进行非天蓝色部署。 You can deploy your extension app or message API endpoint in any cloud provider of your choice.您可以在您选择的任何云提供商中部署您的扩展应用程序或消息 API 端点。 But you have to register the bot either in development portal or azure which will call your extension app.但是您必须在开发门户或 azure 中注册该机器人,这将调用您的扩展应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何(单元)测试方法向 MS Teams 频道发送 http 请求? - How to (unit) test method sending http request to MS Teams channel? Spring Cloud Stream在消息的有效负载中测试硬编码的“Hello World” - Spring Cloud Stream Test hardcoded “Hello World” in message's payload 通过测试从Spring Cloud Stream连接到Message Broker - Connect to message broker with Spring cloud stream from test 服务器套接字-发送测试消息以检测连接 - Server Socket - Sending a test message to detect connection 在Selenuim Automation Test中使用Java连接到MS-SQL服务器 - Connecting to MS-SQL server using Java in Selenuim Automation Test Testcontainers MS SQL Server Module 一直在循环,从不进入测试 - Testcontainers MS SQL Server Module stays in a loop and never enters the test 我可以从chrome扩展程序向Java服务器发送消息吗? - can i send message from chrome extension to java server ? 如何使用Google Cloud Connection Server发送上游GCM消息 - How to use Google Cloud Connection Server to send upstream GCM message Spring Cloud:从配置服务器加载消息源 - Spring Cloud : Load Message Sources from config server 如何使用JUnit测试Neo4j服务器的非托管扩展 - How to test unmanaged extension for Neo4j server using JUnit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM