Sites.selected not working as expected

captain_atharv 511 Reputation points
2022-06-29T09:48:15.09+00:00

Hi,

I want to use Microsoft Search API (https://learn.microsoft.com/en-us/graph/search-concept-overview) for searching. I also want to restrict the search on particular sites. I'm aware I can pass the site-names in query to filter the search, but I want to restrict the access to sites based on permissions. On the app registered in Azure, I have used Sites.Selected and given permission to only 1 site. Then, I have generated user access token using https://learn.microsoft.com/en-us/graph/auth-v2-user?context=graph%2Fapi%2F1.0&view=graph-rest-1.0 as Search API requires delegated token. I have passed scope as Files.Read.All while generating delegated access token. But while calling the Search API, I can see results from other sites as well.
Does Sites.Selected not work with Search API or is Files.Read.All searching across all sites?
How I can achieve site restriction using Search API?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,515 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,561 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,657 questions
0 comments No comments
{count} votes

Accepted answer
  1. HarmeetSingh7172 4,811 Reputation points
    2022-06-29T12:14:13.857+00:00

    Hi @captain_atharv

    Hope you are doing great.

    Per my research, Search Graph API only supports Delegated permissions type (work or school account) and you can check the permissions required for the same here.

    Among these permissions, Files.Read.All will only search Sites libraries across all sites.

    Sites.Selected is currently with the Application Permissions only.

    For achieving site restriction using Search API, you can refer to a similar post.

    Hope this helps.

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

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful