Using GraphAPI to access a folder on a remote customer OneDrive folder (Not just my own OneDrive)

Dror 0 Reputation points
2023-03-30T15:35:09.36+00:00

Hi,

I am trying to write a small application that connects to a customer's OneDrive and folder, then conducts a dir-list on that folder and downloads files from his Drive, which I later process on my application.

I've followed the official instructions describing how to configure the customer's Azure Portal's Active Directory and register a new application with ApplicationID, ClientSecret and proper API Permissions (File.ReadWrite, File.ReadWrite.AppFolder) , then made my application use GraphAPI to authenticate using those identifiers, fetch an access-token and connect using rest-api POST operation, then connecting and using rest-api GET operation to conduct a dir-list.

To my surprise the dir-list returned the directories and files of my own Drive - and NOT the customer's Drive...I can see or download only files from my own Drive, and the customer never see any files I Upload to any directory (of my own Drive, it seems...even though I connected with the customer supplied AppID and ClientSecret)

What am I missing here? Why doesn't the dir-list return the client's Drive and directory content instead of my own Drive's?

p.s I know of an alternative way, to make the customer manually share a folder and send a link by email, which when manually opened and clicked maps his remote folder to my drive, I did manage to scan this mapped folder (which now appears on my Drive) using GraphAPI and download a file, however it feels awkward to have to relay on manual links creation and emails, and I doubt that's the proper way for an application to do it.

Any advise?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,715 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
839 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,137 questions
{count} votes