Search code examples
microsoft-graph-apionedrive

How to share the onedrive file to the people outside of organization


I have a scenario as below:

I have a website and we used the MS Graph API to connect the OneDrive.

The question is when we create a file or files, I want to share it to some one to read it.

If the person is part of organization, it works well. But if a user is not the member in my organization, I get an access denied.

Does anyone know how to connect with anonymous user also authorized user within a same one-drive.

Thanks


Solution

  • According to your description, I assume you want to create a share file to someone that outside of organization.

    We can create a sharelink for a file when we create it by using the following API: POST /drives/{driveId}/items/{itemId}/createLink or POST /me/drive/items/{itemId}/createLink

    In the request body, we should set the scope property to anonymous so that anyone can use the link to get access.

    And we can set type to view to create a read-only link to this file.