O.Dmytriiev
O.Dmytriiev

Reputation: 1

Download certain user's files from SharePoint online

My company has buisness account and domain like \<company>.sharepoint.com So each employee has his own OneDrive space like \<company>-my.sharepoint.com We have special account to manage our documents that are stored on it's own onedrive like this files stored on emploee onedrive

I tried SharePoint CSOM, Microsoft Graph API and SharePointAPI. Using any of it i can get file-related data like name, last change date etc. But when I try to download it using something like this:

var file = clientContext.Web.GetFileByUrl(<url to file>);
var fileStream = file.OpenBinaryStream();
clientContext.ExecuteQuery();

I have exception

File Not Found

Even using https://developer.microsoft.com/en-us/graph/graph-explorer i can't reach my files

also using SharePoint CSOM I can download file from <company>.sharepoint.com/Shared%20Documents/Forms/AllItems.aspx

Is there a way to download files directly from employee documents library, or it's forbbiden and i should move all files to SharePoint 'Communication site' documents?

Upvotes: 0

Views: 408

Answers (1)

O.Dmytriiev
O.Dmytriiev

Reputation: 1

I solwed the problem by using Azure Active Directory App like in this tutorial https://learn.microsoft.com/en-us/graph/auth-v2-service

Upvotes: 0

Related Questions