我已在 Azure AD 上创建了一个应用程序,并已分配 User.Read.All
允许我的应用程序。
话虽这么说,我可以从 Postman 为应用程序生成访问 token 。生成访问 token 时我提供 -
client_id: xxxx
client_secret: yyyy
grant_type: client_credentials
scope: https://graph.microsoft.com/.default
使用生成的访问 token (作为 header Authorization: Bearer zzzz
)我发送 GET
请求https://graph.microsoft.com/v1.0/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="eb81838485c58f848eab8f84868a8285c5888486" rel="noreferrer noopener nofollow">[email protected]</a>
。这给了我错误 -
403 Forbidden
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"request-id": "aaa-bbb-ccc-ddd",
"date": "2019-09-10T12:44:46"
}
}
}
谁能告诉我我做错了什么?
提前致谢。
最佳答案
您需要添加应用程序权限。 未授予权限。 在您的屏幕截图中,我们可以看到它们是委托(delegate)的,这意味着它们仅适用于有用户参与身份验证的情况。 由于您使用客户端凭据身份验证,因此不涉及用户,只涉及应用程序。
当您添加所需的权限时,应该有一个选项可以在“委派”和“应用程序”之间进行选择。 选择应用程序,选择必要的权限并授予它们。
关于azure - 从 Azure AD 获取用户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57871389/