Search code examples
microsoft-graph-apionedrive

Get user list with whom OneDrive Document is shared using Graph API


I am using Graph API to read OneDrive document successfully. I have a requirement to get the list of users with whom the document is shared with. The DriveItem does have the Shared property but it only tells whether is shared with user\organsization\anonymous, however it does give me list of users with whom I have shared the document.

As per documentation

The Shared resource indicates a DriveItem has been shared with others.

{
  "owner": { "@odata.type": "microsoft.graph.identitySet" },
  "scope": "anonymous | organization | users",
  "sharedBy": { "@odata.type": "microsoft.graph.identitySet" },
  "sharedDateTime": "datetime"
}

Is there a way to get shared with "users list" for a given document?


Solution

  • The API supports this via the Permissions resource. Permissions define the level of access provided (read,write,sp.owner, orsp.member`).

    You can return a list of Permissions using the //permissions endpoint of a given file. For example, to /me/drive/items/{item-id}/permissions will return the permissions for the {item-id} in the current user's default Drive.