Interacting with OneDrive Resources Using Microsoft Graph API
By following the aforementioned steps, you can easily access content from other users' OneDrive accounts. Whether you're building a custom application or simply retrieving some files, this approach can save you time and effort compared to manually downloading and uploading files.

As a Microsoft 365 administrator, you may find yourself needing to access content from those users' OneDrive accounts who may have left the organization. Fortunately, the Graphs API makes it easy to do so.
First, it's important to understand what the Graphs API is. Essentially, it's a set of REST APIs that allow you to interact with Microsoft 365 data in a programmatic way. This means you can create custom applications and scripts that can access and manipulate data within your organization's Microsoft 365 environment.
To access content from another user's OneDrive account, you'll need to first authenticate against the Graphs API using your own credentials. Once you've done that, you can use the API to retrieve an access token for the user whose content you want to access.
With the access token in hand, you can then make requests to the OneDrive API to retrieve the content you need. There are a variety of endpoints you can use to do this, depending on the type of content you're looking for.
For example, if you want to retrieve a specific file from another user's OneDrive account, you can use the following endpoint:
GET /users/{user-id}/drive/items/{item-id}
In this case, {user-id} would be replaced with the ID of the user whose OneDrive account you want to access, and {item-id} would be replaced with the ID of the specific file you want to retrieve.
If you want to retrieve all of the files in a particular folder, you can use the following endpoint:
GET /users/{user-id}/drive/items/{item-id}/children
In this case, {user-id} and {item-id} would be replaced with the appropriate values for the user and folder you're interested in.
Permission require:
It's worth noting that in order to access content from another user's OneDrive account, you'll need to have appropriate permissions. Specifically, you'll need to be granted the Files.Read.All permission, which allows you to read all files in all sites without a signed-in user.
- ApiConnectors.ReadWrite.All
- Files.ReadWrite.All
Steps:
To summarize, accessing content from another user's OneDrive account using the Graphs API involves the following steps:
Open the Graph API Explorer at the following URL: https://developer.microsoft.com/en-us/graph/graph-explorer
Sign in and provide consent to Graph Explorer using the User icon in the top-right corner of the screen.
Enter the credentials of the users you want to utilize and grant consent.
Attempt to run the initial API and ensure you receive an OK 200 response along with your details in the Response View.
The first API URL to query other users' OneDrive content is: https://graph.microsoft.com/v1.0/users/user@domain.com/drive/root/children
In cases where you encounter an access denied error when attempting to download content from other users' OneDrive accounts, follow these solutions:
- Ensure that you have Global Admin privileges for the organization, granting the highest level of access, inclusive of other users' OneDrive accounts.
- Grant admin access to other users' OneDrive accounts by navigating through the Admin centers > SharePoint, and following the provided steps.
A. In the left pane, select Admin centers > SharePoint. (You may have to select “Show all” to view the list of admin centers )
B. Input the name of the former employee and click on Find.
C. Under User profiles, select Open.
D. Under People, select Manage User Profiles.
E. Enter the former employee’s name and select Find.
F. Right-click on the user, and subsequently, opt for "Manage site collection owners."
G. Include the user in Site Collection Administrators and click on OK.
Upon successfully executing the aforementioned API calls, you will receive a response listing all the folders and files on the root of the targeted users' OneDrive accounts, each with a unique ID. To obtain downloadable links for files in a specific folder, use the following API calls:
https://graph.microsoft.com/v1.0/users/User@domain.com/drive/items/FOLDERGUID/children?$select=content.downloadUrl,ID,name
These API calls will return a response containing links for each file in the folder, allowing you to download any file by clicking on its respective link. The downloaded file will be saved to your local device.