Microsoft Graph Sites.Selected for app-only access: the gotchas

Microsoft SharePoint logo
Short answer: Sites.Selected lets an app reach only the SharePoint sites you explicitly grant it, which makes it the least-privilege choice for AI agents and MCP servers. With an app-only token, three things catch people out: SharePoint’s /_api REST rejects secret-based tokens, Graph search returns nothing, and sharing links are refused. Use plain Graph file paths instead.
We learned this the hard way. GCIT runs AI coworkers for sales and marketing, finance, ISO compliance, and people and culture, with a person approving every quote and customer communication. When we gave the ISO compliance coworker its own identity, with access to just the one SharePoint site that holds our management system policies, the setup looked right on paper. Then calls we expected to work failed, each in a different way, and search came back empty. This article covers what we found and how to fix it.
Why a business owner should careIf you want an AI assistant or an automation to read your policies, a job register or a client folder, you do not want it holding a key to every file in your Microsoft 365. Sites.Selected is how you give it one room instead of the whole building. The catch is that it takes a few extra, fiddly steps, and the errors do not tell you which step you missed.

Symptoms: what does a Sites.Selected app-only failure look like?

You have consented Sites.Selected for your app in Microsoft Entra ID and granted it access to one site, but calls fail or come back empty. Calls to the SharePoint REST API return 401 with this message:
Unsupported app only token
Calls to the Microsoft Graph /shares endpoint, used to open a pasted SharePoint link, return 403 with this error code, even on the site you granted:
accessDenied
Granting the app access to the site fails with a 400 when the request body is copied from what Graph returns on read:
Invalid request
The quietest symptom has no error at all. A Graph drive search such as search(q='privacy policy'), or a Microsoft Search query, returns an empty result set for a file you can see in the library. People often describe this as “Sites.Selected search not working”, “Graph search empty with app permissions” or “SharePoint app-only token not supported”.

Affected software

  • Services: Microsoft Graph (v1.0), SharePoint Online REST API (/_api), Microsoft Search API
  • Identity: Microsoft Entra ID app registrations using the client credentials flow (app-only, no signed-in user)
  • Typical callers: AI agents, Model Context Protocol (MCP) servers, sync workers and scheduled scripts

Cause: why does a valid app-only token get refused?

Sites.Selected is three locks, not one. Microsoft’s model needs all three before an app gets in: the permission is consented in Entra ID, the app is granted a role on the specific site, and the token the app presents actually carries the permission. Miss any one and access fails. On top of that, each SharePoint surface treats app-only tokens differently.
  • SharePoint REST wants a certificate. Microsoft’s guidance is that app-only access to SharePoint’s REST and CSOM APIs through Entra ID must use a certificate. A token minted with a client secret is rejected with “Unsupported app only token”, even though Microsoft Graph accepts the same kind of token for the same site.
  • Search is not served to Sites.Selected app-only tokens. In our deployments, Graph drive search returned nothing and the Microsoft Search API would not serve the app-only identity at all, while listing folders and downloading files worked on the same token.
  • The sharing-link shim is denied. The /shares endpoint that turns a pasted link into a file reference was refused for our Sites.Selected app-only token, verified live in July 2026, even on the granted site.
  • Granting is a separate, more powerful permission. The call that grants an app access to a site needs Sites.FullControl.All. An app holding only Sites.Selected cannot grant itself anything. In our build, the administrator’s Azure CLI token lacked it too.
  • Admin consent did not always create the assignment. In one of our builds, running admin consent from the Azure CLI did not create the app role assignment, so the token carried no Sites.Selected role.
What worked and what failed with an app-only Sites.Selected token in our builds (Microsoft Graph v1.0 endpoint, client secret credential)
CallResultWhat to do instead
List libraries and folders /sites/{site-id}/drivesWorksUse it as your starting point
Download a file /drives/{drive-id}/items/{item-id}/contentWorksUse it
Open by path /drives/{drive-id}/root:/{path}WorksUse it to resolve pasted links yourself
Drive search search(q='...')Empty resultsBuild your own file index, or search with a delegated identity
Microsoft Search API /search/queryNot servedUse a delegated identity for full-text search
Open a sharing link /shares/{encoded-url}DeniedResolve the link through site, then library, then path
SharePoint REST /_api/...RejectedMove the call to Graph, or use a certificate with the SharePoint Sites.Selected permission
Grant access POST /sites/{site-id}/permissions from the app itselfRefusedRun the grant from a separate admin identity that holds Sites.FullControl.All
Tested by GCIT on our own tenant between June and July 2026 while building an internal AI coworker and our MCP server. Microsoft changes these services often, so recheck against Microsoft Learn before you rely on a “Fails” row.

Resolution: how do you set up Sites.Selected so it actually works?

These steps assume an app registration that reads one site with a Microsoft Graph token. Placeholders in braces are yours to fill in. Never paste real IDs into tickets or chat.
  1. Add the right permission. In the Microsoft Entra admin centre, open App registrations, your app, then API permissions. Add Microsoft Graph, Application permissions, Sites.Selected. Only add the SharePoint version of Sites.Selected if you truly need the REST API, and then use a certificate, not a secret.
  2. Grant admin consent, then check it landed. Select Grant admin consent. Then open Enterprise applications, your app, Permissions, and confirm Sites.Selected is listed as granted. If it is missing, create the assignment directly with POST /servicePrincipals/{client-sp-id}/appRoleAssignments, using the Microsoft Graph service principal as the resource and the Sites.Selected app role.
  3. Find the site’s Graph ID. From an admin identity, call GET /sites/{tenant}.sharepoint.com:/sites/{site-path} and keep the returned id.
  4. Grant the smallest role on that one site. From a separate admin identity that holds Sites.FullControl.All (never the app you are granting), send the request below. Start with read. The create body uses grantedToIdentities. The grantedToIdentitiesV2 shape you see when reading grants back is rejected on create. If you need full control, we found Graph accepted fullControl and rejected the all-lowercase spelling.
POST https://graph.microsoft.com/v1.0/sites/{site-id}/permissions
Content-Type: application/json
{
  "roles": ["read"],
  "grantedToIdentities": [
    { "application": { "id": "{your-app-client-id}", "displayName": "{your-app-name}" } }
  ]
}
  1. Confirm the grant. Call GET /sites/{site-id}/permissions and check your app appears with the role you expect. This is also the fastest check when access stops working later.
  2. Request a Graph token, not a SharePoint one. Use the client credentials flow with the scope https://graph.microsoft.com/.default. Decode the token and check the roles claim includes Sites.Selected. If it does not, go back to the consent step and check the assignment.
  3. Move SharePoint REST calls to Graph. Anything you did through /_api (list items, files, folders) has a Graph equivalent under /sites/{site-id}. Start from /sites/{site-id}/drives, then walk folders or address files by path.
  4. Resolve pasted links yourself. Do not send links to /shares. Match the link to the site, then to the library whose web address is the longest prefix of the link, then open the rest as a path under that library’s root.
  5. Build your own index if you need search. Enumerate the libraries you care about, skip system libraries, cap how far you walk, and match on file name and folder path. Refresh it on a schedule, or use Microsoft Graph delta queries to pick up changes. Skip unchanged files by their eTag.
  6. Verify. List the site’s libraries, open one known file by path and download it with the app-only token. Then try a site you did not grant and confirm it is refused. Both results matter: the first proves access, the second proves the boundary.

Three locks, all required

Consent in Entra ID, a role on the site, and a token that carries the permission. If access fails, check them in that order.

Graph, not SharePoint REST

Secret-based app-only tokens work in Microsoft Graph and are refused by /_api. Move the call rather than fight it.

No search, so index

Search comes back empty for app-only Sites.Selected. List the libraries and match on name and path, or search with a delegated identity.

Keep the granter separate

The grant needs Sites.FullControl.All. Hold that on a tightly controlled admin identity, never on the agent that reads the data.

Important notes: what should you watch for?

  • Prefer no stored secret at all. Where the app runs in Azure, a managed identity can be set up as a federated credential on the app registration, so there is no secret to leak or expire. For a regional accounting practice, the scheduling portal’s SharePoint sync is read-only with no stored secret. It pulls the practice’s workbooks from one site it has been granted read on, and skips workbooks that have not changed.
  • If you must use SharePoint REST, use a certificate and the SharePoint (not Graph) Sites.Selected permission. Treat the private key like a password and rotate it.
  • Mint tokens for one named tenant. Configure the tenant explicitly and refuse to request a token when it is missing, rather than falling back to a default. A silent fallback is how one customer’s agent ends up pointed at another tenant.
  • Finer-grained scopes exist. Microsoft now offers Lists, ListItems and Files versions of the Selected model. Granting at those levels breaks permission inheritance on the item, so plan for SharePoint’s limits on unique permissions.
  • Granted is not the same as safe. Sites.Selected limits where an app can go, not what it does once there. Pair it with read-only tools, logging and a person approving any change.
The honest limitationA file index built from names and folder paths is not full-text search. Our ISO coworker finds a policy called “Information Security Policy” easily, but it will not find a sentence buried inside a document whose name gives no clue. For content search you need a delegated identity (a licensed account with its own permissions) or your own text index, and either one is more to build, secure and maintain. The index can also lag behind the library between refreshes.
For your IT lead: how our MCP server routes SharePoint calls
Our Model Context Protocol (MCP) server for Microsoft 365 support work handles this by design rather than leaving it to each technician.
Routing
Each SharePoint call tries the app-only route first. If that route is refused for any reason (no grant on the site, or a token type that API will not accept), it falls back to the technician’s own delegated access, and remembers per site which route worked so the next read skips the failed probe. Writes always try app-only first, because a failed read must never push a write onto a weaker identity.
Grants
A dedicated tool grants the worker app a role on one named site, defaulting to read. A second tool lists the grants in effect on a site, which answers “is it actually granted, and at what role?” in one call.
Errors
When both routes fail, the error names the real blocker and the fix, instead of a generic access denied.
Standard
Our standard approach for client MCP servers: check first whether one already exists, sign in with your own Microsoft 365 identity and roles, the granted tool list is a signed scope deliverable, write access starts at ‘propose’ (a person approves), systems of record stay read-only, and every server ships a help tool and a way to report tool problems.

Frequently asked questions

It is a Microsoft Graph permission that gives an app no SharePoint access until someone grants it a role (read, write, owner or full control) on a specific site. It is the least-privilege alternative to Sites.Read.All, which opens every site in the tenant the moment it is consented.

SharePoint’s REST and CSOM APIs only accept Entra ID app-only tokens obtained with a certificate. A token from a client secret is rejected. Either move the call to Microsoft Graph, which accepts it, or switch the app to a certificate and add the SharePoint Sites.Selected permission.

Not with an app-only token, in our experience. Drive search returned nothing and the Microsoft Search API would not serve it. Listing and downloading work, so build a name and path index, or run search through a delegated identity that has its own licensed account.

An identity with Sites.FullControl.All, either an app with that application permission or a signed-in SharePoint administrator. Keep that identity separate from the app being granted, and record each grant against a change request so you can review and remove it later.

It limits the agent to the sites you grant, which is the right starting point. It does not control what the agent does inside those sites, so combine it with read-only tools where possible, logging of every action, and a person approving any change.

No. If the app runs in Azure, a managed identity set up as a federated credential avoids storing a secret. Outside Azure, a certificate is the stronger choice, and it is required anyway for SharePoint REST.

An MCP server is how Claude reaches your business systems. When that server reads SharePoint on its own schedule, with no user signed in, it needs app-only access, and Sites.Selected is how you keep it to the sites the job requires. The gotchas on this page decide which Graph calls the server can use.
Last reviewed

Want an AI agent to read SharePoint without the keys to everything?

We set up least-privilege access for MCP servers and automations, and we can fix one that is stuck on these errors.
AI Discovery Workshop A$695 ex GST, credited in full if you go ahead. Start with a free discovery call.
Was this article helpful?
Ready to secure and simplify your IT? Talk to a GCIT expert today.