General question about file search with graph

MSAPINewbie 26 Reputation points
2021-08-15T15:48:47.337+00:00

Hello, once again I have a question about the MS Graph SDK for ASP Net Core (C#):

Do I have to be logged in to start the search from Files(One Drive) ? Or is this also possible as daemon-services (like webhooks with MS Graph)(not delegated) ?

About answer I would be very happy

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,558 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JosephXu-MSFT 531 Reputation points
    2021-08-16T05:52:52.21+00:00

    Hi @MSAPINewbie Yes, we can search Files in One Drive without logged in.

    1. To do that we need to add app permissions. The permissions are shown in the figure below.
      123428-image.png
    2. Then click Grant admin content for ...
      123446-image.png
      Or use the tenant-wide admin consent URL follows the following format: https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}

  2. MSAPINewbie 26 Reputation points
    2021-08-16T08:27:37.433+00:00

    Hello and thank you for your answer,

    I have the problem with my daemon application that when I want to search a special folder for a file the count is always 0.
    By the way, I can still run a webhook (with delta query) with my Deamon application.

     private async Task<IDriveItemSearchCollectionPage> SearchFiles(GraphServiceClient graphClient){
      var search = await graphClient.Drives["{Drive-id}"]
                                     .Items["{user-id]"]
                                     .Search("Filename") //todo
                                     .request()
                                     .GetAsync();
    
         return search;
     }
    

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.