2

What is the correct way to determine a file’s access permissions on OneDrive when using MSGraph API? Specifically, how can I tell if the caller can edit the file?

I used the list permissions API and I get a collection of permission objects. The docs state that:

The permissions collection includes potentially sensitive information and may not be available for every caller.

  • For the owner of the item, all sharing permissions will be returned. This includes co-owners.
  • For a non-owner caller, only the sharing permissions that apply to the caller are returned.
  • Sharing permission properties that contain secrets (e.g. shareId and webUrl) are only returned for callers that are able to create the sharing permission.

I tried to list the permissions on an item that was shared with the caller and the list I got included grantedTo entries for other users than the calling user despite what the docs say. Actually, no grantedTo entry was specified for the user I was calling with. The list also included a link permission entry. Can I assume that entry applies to the calling user?

I couldn’t find anything in the docs that explains how to use the list to know whether the user has read or write access to the file.

Should I iterate the list and look for grantedBy entries that match the current user’s id? Should I look at the link entries’ roles too? If there is such an entry with a write role, does that mean I can upload a new version of that file?

galsh83
  • 550
  • 3
  • 16

0 Answers0