Query Files of another One Drive for Business User's Files using MS Graph API as Global Admin

Gagan Bhatnagar 26 Reputation points
2022-11-24T11:17:36.997+00:00

Hello,

I can query my own One Drive for Business account files as 'The Global Admin' using Microsoft Graph API. I cannot query another One Drive for Business user's files as 'The Global Admin' using Microsoft Graph API.

Own Files: https://graph.microsoft.com/v1.0/me/drive/root/children

Another User: https://graph.microsoft.com/v1.0/users/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/drive/root/children

I am using an Azure AD registered app with following Application permissions:

Files.ReadWrite.All
Sites.Read.All
Sites.ReadWrite.All
User.ReadWrite.All
offline_access
However, when I go to Office 365 Admin and Choose that another One Drive for Business user (for which I could not query files using MS Graph API) => OneDrive => Get access to files => Click Create link files then I can successfully query that another user's files using MS Graph API.

One Drive for Business User

If Global Admin needs to query files of all user accounts using MS Graph API when there are 100s of users then this method might not be practical.

Is there any easier way or programmatically possible to give Global Admin the permissions to query files of all user accounts using MS Graph API. If yes, how do we do that.

Thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,521 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,655 questions
{count} vote

Accepted answer
  1. Srinivasa Rao Darna 6,686 Reputation points Microsoft Vendor
    2022-11-24T14:07:36.95+00:00

    Hello @Gagan Bhatnagar ,

    With delegated permissions you can only fetch files that you have access on, even if a global administrator.
    Consider Get access without a user, using application permissions can access all users OneDrive files.

    263907-image.png

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful