You can use the Microsoft Graph endpoint to interact programmatically with your tenant data. A common scenario is to use a Microsoft Graph /users endpoint to look up users in the tenant. In this case, if you use delegated permissions in your access token, the User.Read.All permission is necessary. There are ways to prevent you from looking up other users, such as using an authorizationPolicy object that can control Microsoft Entra authorization settings, unless you're a tenant administrator.
This article provides a solution to an issue where you can't look up other users using the Microsoft Graph /users endpoint after a tenant policy configuration restricts access to other users.
Symptoms
After you enable an authorizationPolicy object in your tenant to prevent the user lookup action, a new application receives a 401 HTTP response when it performs this action. This issue occurs even though the proper permissions are consented to during app registration and the access token has the proper permissions.
Cause
The allowedToReadOtherUser property in the authorizationPolicy is set to false. This setting prevents the default user role from reading other users. You can check its value via a GET request:
GET https://graph.microsoft.com/v1.0/policies/authorizationPolicy
Solution
To resolve this issue, set the value of the allowedToReadOtherUser property to true via a PATCH request as follows:
PATCH https://graph.microsoft.com/v1.0/policies/authorizationPolicy
{
"defaultUserRolePermissions": {
"allowedToReadOtherUsers": true
}
}
Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
