Read a shared one drive folder of a user in the .Net application

Mihir Hundiwala 20 Reputation points
2025-04-04T12:17:24.6033333+00:00

I need to create a program which will read the files and its meta data present in a folder. This folder will be a shared one drive folder from one of the user of my organization. I am confused as to how the program will read that folder.I know that we will have to use Microsoft graph API and will need an azure app registration.

My questions are:

  1. Is it possible for a program (which has been given access to a folder) to read the folder's content?
  2. What permissions do I need to give to the azure app?
  3. Will it be delegated or application level permissions?
  4. To whom will the user share this one drive folder with, if I use delegated flow, then the user will be sharing the folder with a service account email that will be used to authenticate graphClient but with whom will the user share the folder if the authentication is done without a user (i.e., application level flow and not delegated)?

If I use delegated, then I will have to create a graphClient on behalf of a user that has access to the shared folder right? Or do I need to use application level (for background programs or daemon services) permissions. the application level permission had "__ . __ . All" type of permissions. I dont want the app to access all the folders of all the users. The user will mention the folder on my website that needs to be read and I only want access to the shared folder, how can I achieve it?

Other question:

  1. What inputs do I need from the user? Email, Folder Name/path or a sharing url (sharing urls also has different formats which needs to be taken care of)
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,483 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mohan Joshi-MSFT 580 Reputation points Microsoft External Staff
    2025-04-04T14:05:18.12+00:00

    Hi Mihir Hundiwala,

    Thanks for reaching out to Microsoft!

    Yes, it is possible for a program to read the contents of a shared OneDrive folder using the Microsoft Graph API. You will need to ensure that the program has the necessary permissions to access the folder.

    https://learn.microsoft.com/en-us/onedrive/developer/rest-api/concepts/using-sharing-links?view=odsp-graph-online

    The permissions required depend on whether you are using delegated or application-level permissions:

    • Delegated Permissions: These are used when your app is acting on behalf of a user. You will need permissions like Files.Read, Files.ReadWrite, or Files.Read.All
    • Application Permissions: These are used when your app is running as a background service or daemon. Permissions like Files.Read.All or Files.ReadWrite.All are required. However, these permissions grant access to all files in all site collections, which might be broader than what you need

    https://learn.microsoft.com/en-us/onedrive/developer/rest-api/concepts/permissions_reference?view=odsp-graph-online

    You will need the inputs from user like Email, Folder Name and sharing URL.

    Even after verifying the above, if the issue still persists, I recommend you raise a support case with Microsoft Graph, a Support Engineer will be able to look into this issue and assist you better. You can raise support ticket from New support request - Microsoft Entra admin center or https://admin.microsoft.com/#/support/requests.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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