How to use SharePoint search query with SharePoint Granular access permissions?

Copper Contributor

I want to execute SharePoint search API with granular access for that I've changed
'Sites.ReadWrite.All' permission to 'Sites.Selected' permission, so that application would have all sites access but during search I'm getting unauthorize error
```
{"odata.error":{"code":"-1, Microsoft.Office.Server.Search.REST.SearchServiceException","message":{"lang":"en-US","value":"Unauthorized."}}}
```

Also tried to give sites.selected permission at tenant level, that also not works, if the only solution is to give 'Sites.ReadWrite.All' or 'Sites.Read' then there is no use of granular level access implementation Sites.Read.all will allow all sites if granted.

 

My query is similar to below -:
https://tenant.sharepoint.com/_api/search/query?querytext='*+AND+(Path:"https://tenant.sharepoint.com/sites/SITE1/RECORDS" OR Path:"https://tenant.sharepoint.com/sites/SITE2/RECORDS")'&trimDuplicates=false&selectProperties='Column1,Column2'&refiners='Column1OWSTEXT'&refinementFilters='Column1:equals(\"xxxxx\")'&rowLimit=5

 

Some other references regarding my question.
https://sharepoint.stackexchange.com/questions/306397/how-to-use-sharepoint-search-query-with-sharep...
https://sharepoint.stackexchange.com/questions/306432/is-that-sites-selected-permissions-level-allow...

 

Really appreciate any response on this or alternative approach to to achieve this.

 

0 Replies