"Insufficient privileges to complete the operation" 仅部分用户出现错误

"Insufficient privileges to complete the operation" error for only some users

我正在尝试让 Azure AD 组成为以下成员的用户:

https://graph.microsoft.com/v1.0/users/<user_id>/memberOf

对于某些用户,我收到了请求的信息,但对于其他用户,我收到了此错误:

{
    "error": {
        "code": "Authorization_RequestDenied",
        "message": "Insufficient privileges to complete the operation.",
        "innerError": {
            "request-id": "fd9345ee-ee2f-4dfb-b7e8-ca53d0c804d9",
            "date": "2019-07-03T15:50:25"
        }
    }
}

我正在使用客户端 ID + 客户端密码获取令牌。

该应用拥有这些特权:

(Application) Groups.Read.All
(Application) Users.Read.All

因为我正在为一些成员获取组,所以这似乎并不是缺少 Azure 应用级别的权限。

你能帮我解决这个问题吗?

提前致谢!

PS: Caiyi Ju 修复: "Since you are using client credential flow, you need to grant Directory.Read.All permission (application)."

您需要 Directory.Read.All Delegated 许可 您可以 check here

看看你是怎么做到的。

Delegated Directory.Read.All权限

添加权限后不要点击Grant Consent

Post 人测:

由于您使用的是客户端凭证流,因此您需要授予Directory.Read.All权限(应用程序)。