Service principal access to sharepoint online

Sourav 100 Reputation points
2024-11-07T20:22:24.9333333+00:00

Hello

I have created a service principal in Entra and this will be used by power automate or ADF to connect to a particular sharepoint online site to read and copy files from the sharepoint online.

Could you please tell me what permissions are required :

  1. What all API permission in Entra is required so that access is granted to only one particular sharepoint site ?
  2. Please provide the detailed steps. Should I use delegated or application permission in the API permission in Entra ?
  3. Can we do this via portal and also via powershell command and how ? I have already created the service principal.

Thanks!

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,820 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,101 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Luis Arias 7,121 Reputation points
    2024-11-07T21:05:42.4733333+00:00

    Hello Sourav,

    To connect a service principal to a specific SharePoint Online site and allow it to read/copy files, follow these steps:

    • API Permissions in Entra ID
      Go to Azure Active Directory > App registrations > select your service principal > API permissions. Add the following Microsoft Graph permissions with Application access:
      • Sites.Read.All: General read access across SharePoint.
      • Sites.Selected: Allows limiting access to specific sites.
        Grant admin consent for these permissions.
    • Grant Access to a Specific SharePoint Site
      Use PowerShell to assign site-level access with Sites.Selected:
      1. Install SharePoint Online Management Shell:
             Install-Module -Name Microsoft.Online.SharePoint.PowerShell
        
      2. Connect to SharePoint Online:
             Connect-SPOService -Url https://[your-tenant-name]-admin.sharepoint.com
        
      3. Grant access to the site:
             Grant-SPOSiteDesignRights -Identity "[Site URL]" -Principals "[App ID]" -Rights View
        

    References

    If the information helped address your question, please Accept the answer.

    Luis


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.