我正在尝试创建一个 api,将消息发送到团队中的特定 channel 或群组。
我正确地遵循了文档。在Azure中,我向我的应用程序授予了所有权限。 她配置了 tenandId、clientId 和 SecretId,但是当我发送请求时,我得到了这个返回。
有谁知道解决方案或遇到过此错误吗?
最佳答案
您的代码当前正在尝试使用 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.
关于java - 图错误: Invoked API requires Protected API access in application-only context when not using Resource Specific Consent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69305372/