java - 图错误: Invoked API requires Protected API access in application-only context when not using Resource Specific Consent

标签 java node.js azure api microsoft-teams

我正在尝试创建一个 api,将消息发送到团队中的特定 channel 或群组。

我正确地遵循了文档。在Azure中,我向我的应用程序授予了所有权限。 她配置了 tenandId、clientId 和 SecretId,但是当我发送请求时,我得到了这个返回。

有谁知道解决方案或遇到过此错误吗?

enter image description here

enter image description here

文档: https://learn.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=javascript

最佳答案

您的代码当前正在尝试使用 GET HTTP 请求(即代码中的 .get() 部分)来读取消息

如果您想要发送消息,那么您需要通过将 .get() 更改为 来发出 POST 请求。发布(channelMessage)

有关 protected API 的更多信息

根据"Protected APIs" documentation :

Microsoft Teams APIs in Microsoft Graph that access sensitive data are considered protected APIs. These APIs require that you have additional validation, beyond permissions and consent, before you can use them.

个人消息似乎是敏感数据,这是有道理的。但请注意,还有一种替代解决方案,您可以像用户使用 API 一样使用 API。它被称为Delegated permissions .

Delegated permissions are used by apps that have a signed-in user present. For these apps, either the user or an administrator consents to the permissions that the app requests and the app can act as the signed-in user when making calls to Microsoft Graph. Some delegated permissions can be consented by non-administrative users, but some higher-privileged permissions require administrator consent.

如果您无法选择委派权限,您仍然可以向 Microsoft Graph 发出正式请求,请求获得使用 API 的权限,而无需任何用户交互。

To request access to these protected APIs, complete the following request form. We review access requests every Wednesday and deploy approvals every Friday, except during major holiday weeks in the U.S. Submissions during those weeks will be processed the following non-holiday week.

Here is the form for sending a formal request.

关于java - 图错误: Invoked API requires Protected API access in application-only context when not using Resource Specific Consent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69305372/

相关文章:

python - Azure Synapse 开发(代码编写)最佳实践

r - 如何在机器学习工作室笔记本中使用 R 生成 PDF 文件并上传到 Blob 存储

java - 将整数移动零次有什么影响?

javascript - 在传单中创建一个圆圈而不重新加载 WebView

java - 需要帮助了解程序的执行

javascript - 使用 Javascript 可选调用函数 "class"

java - 从 Android 移动应用发送消息到 Azure IoT 中心

javascript - WebSocket 构造函数是原生 Javascript 吗?

javascript - 如何在 try catch block 中使用 const

c# - 从 Azure 函数调用 Asp.Net Web API 端点