A cloud-based identity and access management service for securing user authentication and resource access
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:
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"
}
}]
}
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
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
When tried to access another SharePoint site, received 403 error:**
Let me know if any further queries - feel free to reach out!