General question about file search with graph

MSAPINewbie 26 Reputation points

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.
10,836 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JosephXu-MSFT 531 Reputation points

    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.
    2. Then click Grant admin content for ...
      Or use the tenant-wide admin consent URL follows the following format:{tenant-id}/adminconsent?client_id={client-id}

  2. MSAPINewbie 26 Reputation points

    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}"]
                                     .Search("Filename") //todo
         return search;