The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Hi @Ali Jone
Thank you for posting your question in the Microsoft Q&A forum.
Based on this documentation Use the Microsoft Search API to query data - Microsoft Graph v1.0 | Microsoft Learn. Sites.Selected is not listed under the permission scopes. The documentation also notes that the Search API does not support the site-level search schema. Instead, it uses the tenant-level or default search schema.
Therefore, the behavior you observed is expected. The Microsoft Graph Search API (/search/query) does not enforce Sites.Selected in app-only scenarios. Search always operates against the tenant-wide SharePoint search index, and Sites.Selected is not evaluated at query time.
Sites.Selected applies only to SharePoint site APIs, such as:
- /sites/{id}
- /sites/{id}/drives
- /sites/{id}/lists
- /sites/{id}/permissions
It does not apply to:
- /search/query (Graph Search)
- SharePoint legacy search API /_api/search/query
About the wids claim:
-The wids claim does not grant SharePoint permissions and does not override Sites.Selected.
-It represents internal workload identity classifications automatically included in app-only access tokens.
-These are not Microsoft Entra directory roles, do not grant access to SharePoint content, and do not affect Search API scope.
-There is no evidence in Microsoft documentation or support cases that the wids claim overrides Sites.Selected or changes SharePoint authorization behavior.
There is currently no supported way to enforce Sites.Selected restrictions on Microsoft Graph Search.
You can use Drive or List APIs:
- GET /sites/{site-id}/drives/{drive-id}/root/children
- GET /sites/{site-id}/lists/{list-id}/items?$filter=...
These endpoints respect Sites.Selected, but they do not support full-text search.
I hope this information is helpful.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.