【发布时间】:2020-12-28 16:35:31
【问题描述】:
无法在 SharePoint 框架 (SPFx) webpart 中使用 MSGraphClient 将成员添加/删除到具有 Group.ReadWrite.All 和 User.Read.All 权限的 O365 私有组。
我已从 SharePoint Admin API 访问页面批准权限,以便我的“SharePoint Online 客户端可扩展性 Web 应用程序主体”获得所需的委派权限。甚至尝试使用 GroupMember.ReadWrite.All 和 Directory.ReadWrite.All 权限。
POST https://graph.microsoft.com/v1.0/groups/{groupid}/members/$ref
{
"@odata.id": "https://graph.microsoft.com/v1.0/users/{userid}"
}
也试过下面的身体
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{userid}"
}
以下是错误文本:
Uncaught (in promise) Error: Error making HttpClient request in queryable [403] Forbidden ::> {
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"date": "2020-09-09T20:18:44",
"request-id": "ea951e6c-ae43-4907-8c86-e6f6c8346462"
}
}
}
当我使用 O365 帐户而不是组所有者帐户登录时,我收到此错误。当我使用 Group Owner 帐户运行相同的代码时,它工作正常。
【问题讨论】:
-
权限好像没有生效。能否提供 Azure AD 应用中配置的委派权限的屏幕截图?
-
用截图更新了帖子
-
解析jwt.io中的访问令牌以检查它是否包含所需的权限。
-
是的,它显示了所需的权限
-
如果任何答案对您有帮助,您可以接受它作为答案(单击答案旁边的复选标记,将其从灰色切换为已填充。)。见meta.stackexchange.com/questions/5234/…。这对其他社区成员可能是有益的。谢谢。
标签: microsoft-graph-api sharepoint-online spfx