0
votes

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?

1
have you checked if the client context that you initialize has access to a user's one drive - Documents docLibrary? - jimas13
Yes I`m prety shure it hava acces becouse I used my own login and password and tried to download file - O.Dmytriiev
in case you are using your account, you have access to your own document library. you cannot access different people's document libraries without adding permissions to your account. - jimas13

1 Answers

0
votes

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