Search code examples
onedrivemicrosoft-graph-api

Microsoft Graph .NET SDK: Getting items from mycompany.sharepoint.com/Shared%20Documents


Debugging the code, I see the request is like: https://graph.microsoft.com:443/v1.0/drives/the-shared-docs-id/items/the-root-id/children

I know for sure that the-shared-docs-id and the-root-id are right. Furthermore, this same request returns the expected results when issued from the Graph explorer.

However, the .NET SDK returns nothing. No items at all. The same user (me) created the files and folders, and authorized the app to access OneDrive. This user is even the admin of everything.


Solution

  • I was testing with two different apps, one with Files.ReadWrite scope only, and other with Files.ReadWrite.All.

    I thought Files.ReadWrite.All was needed to access other user's files. It turns out, it is also needed to access the shared folder, even being the same (admin) user who created the shared items (files and folders), and even having full permissions to access them.

    I think this is weird... but it looks like this is the way it is.

    Using the app with Files.ReadWrite.All scope, I was able to see the items in the shared folder.

    Using the Files.ReadWrite scope, I get an empty list of items.