Unable to Assign Sites.Selected Write Access to a Single SharePoint Site: Grant-PnPAzureADAppSitePermission Failing

Gamage 20 Reputation points
2025-12-10T11:25:35.4133333+00:00

Hi everyone,

I’m trying to configure restricted SharePoint access for an automation workflow (n8n chatbot). My goal is to allow an Azure App Registration to access ONE SharePoint site only using Sites.Selected with Write permissions.

However, I keep running into multiple PowerShell errors and cannot successfully grant the permission.

✔ What I already did

1. App Registration (Azure Entra ID)

Created an App Registration using an admin account.

Added API Permissions: Sites.Selected (Application) & Files.ReadWrite.All (Application)

Created a Client Secret.

2. SharePoint Setup

Created a dedicated site ONLY for my specific work

3.Installed PnP.PowerShell Using PowerShell 7.5.4

Whenever I try to connect or grant the permission, I get errors.

ERROR 1 — Connect-PnPOnline -Url "https://

Microsoft Security | Microsoft Entra | Microsoft Entra ID

Answer accepted by question author
Rukmini 44,000 Reputation points Microsoft External Staff Moderator
2025-12-10T20:35:09.8666667+00:00

Hello Gamage,

To restrict Sites.Selected SharePoint API permission to apply only to one specific site, not the whole tenant, make sure your app is granted the Sites.Selected permission:

User's image

Now create a permission to restrict the application to access only one SharePoint site. To perform this, refer this Microsoft Document for permissions:

YAML

POST https://graph.microsoft.com/v1.0/sites/{siteId}/permissions
{
  "roles": ["write"],
  "grantedToIdentities": [{
    "application": {
      "id": "ClientIDofApp",
      "displayName": "ruk33"
    }
  }]
}

User's image

Generated access token using client credentials flow:

YAML

POST https://login.microsoftonline.com/tenantId/oauth2/v2.0/token
grant_type:client_credentials
client_id: appId 
client_secret: secret 

User's image

Using the above access token, the app can access ruk33 site:

JSON


GET https://graph.microsoft.com/v1.0/sites/m365xxx.sharepoint.com:/sites/ruk33

User's image

When tried to access another SharePoint site, received 403 error:**

User's image


Let me know if any further queries - feel free to reach out!

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.