Who's Online
15 visitors online now
0 guests, 15 bots, 0 members
Support my Sponsor
  • An error has occurred, which probably means the feed is down. Try again later.

Download content from others OneDrive using Graphs API

Explained the same using my Youtube channel : https://www.youtube.com/watch?v=YG19odJN94Q

If you want to download content from other users’ OneDrive accounts, you have a few options. The simplest option is to create a OneDrive link for each user using the Office 365 Admin center. This will allow you to access and download their files through a web browser. However, this option is not very efficient if you have to do it for many users. A better option is to use an API call that can create a custom application for you. This application can download the files for multiple users at once, without requiring you to create individual links. To use this option, you need to follow these steps to get the API calls for the custom application.

Open Graphs API explorer URL : https://developer.microsoft.com/en-us/graph/graph-explorer

Sign in and give consent to Graphs explorer using the User icon on right corner of the screen

Now type the credentials of the users you want to use and give consent.

Now try to run the initial API and confirm you get OK 200 and your details in the Response View

Now the 1st API URL using which you can query other users OneDrive content is https://graph.microsoft.com/v1.0/users/[email protected]/drive/root/children

Sometimes, when you try to download content from other users’ OneDrive accounts, you may encounter an access denied error. This means that you do not have the permission to access their files. To fix this error, you need to do one of the following things:

  • Make sure that you are a Global Admin for the organization. This role gives you the highest level of access to all the resources in the organization, including other users’ OneDrive accounts.
  • Grant admin access to other users’ OneDrive accounts by following these steps:
  1. In the left pane, select Admin centers > SharePoint. (You might need to select Show all to see the list of admin centers.)
  2. If the classic SharePoint admin center appears, select Open it now at the top of the page to open the SharePoint admin center.
  3. In the left pane, select More features.
  4. Under User profiles, select Open.
  5. Under People, select Manage User Profiles.
  6. Enter the former employee’s name and select Find.
  7. Right-click the user, and then choose Manage site collection owners.
  8. Add the user to Site collection administrators and select OK.

This option allows you to specify which users’ OneDrive accounts you want to access, without requiring you to be a Global Admin.

After you successfully execute the above API calls, you will get a response that shows you the list of all the folders and files on the root of the other users’ OneDrive accounts. Each folder and file will have a unique ID that you can use to access its contents. To get the downloadable links for all the files in a specific folder, you need to use the following API calls:

https://graph.microsoft.com/v1.0/users/[email protected]/drive/items/FOLDERGUID/children?$select=content.downloadUrl,ID,name

These API calls will return a response that contains the links for each file in the folder. You can download any file by clicking on its link. The file will be saved to your local device.

Comments are closed.