0

My one drive for business has URL of the form:

https://XXXXXXX-my.sharepoint.com/personal/AA_BBBB_com/_layouts/15/onedrive.aspx

How to download the files from the above looking URL?

I'm building an client APP which needs to download files from the above URL at scheduled intervals. I have client_id and client_secret.

My method of attack has been to to use microsoft GRAPH API and MSAL library to download the files from the above url.

I have seen examples of using graph api to download files from one drive (NOT one drive for business).

1 Answers1

0

In order to get files from a drive using graph, you would use one of the following:

GET /drives/{drive-id}/items/{item-id}
GET /drives/{drive-id}/root:/{item-path}
GET /groups/{group-id}/drive/items/{item-id}
GET /groups/{group-id}/drive/root:/{item-path}
GET /me/drive/items/{item-id}
GET /me/drive/root:/{item-path}
GET /sites/{siteId}/drive/items/{itemId}
GET /sites/{siteId}/drive/root:/{item-path}
GET /users/{userId}/drive/items/{itemId}
GET /users/{userId}/drive/root:/{item-path}

Reference: https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get?view=odsp-graph-online

In your case, you can use this as an example to get items from your own OneDrive:

https://graph.microsoft.com/v1.0/me/drive/root/children

You will need a bearer access token using the clientid and secret that you currently have to make this request that has permission and scopes to this account and files.

Reference: https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http#list-children-in-the-root-of-the-current-users-drive

Brian Smith
  • 1,467
  • 15
  • 31