call https://graph.microsoft.com/v1.0/users with $filter failed with error: Insufficient privileges to complete the operation.

Thanh Nguyen Chi 0 Reputation points
2023-03-07T03:55:45.0766667+00:00

When I call GraphAPI: https://graph.microsoft.com/v1.0/users?$top=6&$filter=userType%20ne%20%27Guest%27&$search=%22displayName:flow%22%20OR%20%22mail:flow%22 with $filter parameter. It throws an error:

User's image

If I removed the $filter parameter it works well and return the list of user:

Capture

Here is API Permission I configured for the App Registration:
User's image

Note: The Application Registration was configured as Multi-Tenant and this App Registration is from my Azure (For example Tenant A) Tenant. And the API works well with the Token of the User of Tenant A. But If I use a token of a user belonging to a different tenant, then the issue above happened.

Expected:

I can query the list user with $filter

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Zehui Yao_MSFT 5,881 Reputation points
    2023-03-07T05:50:57.7966667+00:00

    Did you add header: 'ConsistencyLevel: eventual'? In my test, the run was successful by adding header.

    User's image

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Thanh Nguyen Chi 0 Reputation points
    2023-03-08T02:24:13.3066667+00:00

    Hi @Zehui Yao_MSFT

    The issue you're talking is a different issue. Your issue is "Request_UnsupportedQuery" but our case is: "Authorization_RequestDenied"

    User's image

    And our situation is quite complicated because we request to GraphAPI with the access_token of an external user. I tried to explain to you below:

    issue - cannot get list of user with filter param

    Could you please take a look the image and I have a question in the Summary.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.