Restrict app access of graph apis to specific folder of share point

Geetika Garg 0 Reputation points
2025-01-08T06:24:40.83+00:00

I want to restrict access of an app for specific folder in a site. I have created an app with Site.Specific permission.
I have created another admin app with Full Access. Now when I try to provide folder level access to the site specific app, I get error of Invalid Request.
Api end point POST call : https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/items/{folder-id}/permissions

How to fix this.
Note: It works for site level access but not working for folder level access

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,723 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,028 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 111.4K Reputation points MVP
    2025-01-08T07:12:29.1633333+00:00

    Can you clarify what is the exact request you are making? To grant permissions to specific item(s) only, you need to use the following request:

    POST https://graph.microsoft.com/v1.0/sites/{siteId}/drives/{driveId}/items/{itemId}/permissions
     {
        "roles": [
            "write"
        ],
        "grantedTo": {
            "application": {
                "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
            }
        }
    }
    

    Note the use of grantedTo facet instead of grantedToIdentities which you'd use for Site-level permissions


  2. CarlZhao-MSFT 44,436 Reputation points
    2025-01-08T09:38:58.83+00:00

    Hi @Geetika Garg

    As far as I know, you can only restrict access for an application to specific sites, not specific folders. There are currently no fine-grained permissions for the folder level.

    References: https://learn.microsoft.com/en-us/graph/api/site-post-permissions?view=graph-rest-1.0&tabs=http.


Your answer

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