I want to get folders and files name with downloadable url.

shenlaroche 0 Reputation points
2024-03-11T06:39:36.1033333+00:00

I have code for getting folders and files with downloadable URLs but I just want how to create an access token for that API (

https://graph.microsoft.com/v1.0/users/{user-id/drive/root

). Also, I want to know the required scopes for the registered app. I want server-to-server access. Please help me with this problem.

Thanks.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,346 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,515 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 45,921 Reputation points
    2024-03-12T09:25:32.1033333+00:00

    Hi @shenlaroche

    It seems that your working environment is an app-only context (unattended), then you need to grant Files.ReadWrite.All application permission to the calling app and grant admin consent, after which use daemon based client credentials flow request access token.

    GET https://graph.microsoft.com/v1.0/users/{user-id}/drive/root/children
    

    User's image

    Note that we can only download files and not folders, so the @microsoft.graph.downloadUrl property is not returned for folder items. You need to list all the files in the folder.

    https://graph.microsoft.com/v1.0/users/{user-id}/drive/items/{folder-id}/children
    

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.