Sharepoint permissions

Roger Roger 6,041 Reputation points
2024-09-19T22:29:36.2166667+00:00

Hi All,I have a SharePoint site, let's call it "tempsite," and I have generated a Client ID using the following URL:

https://contoso.sharepoint.com/sites/tempsite/_layouts/15/appregnew.aspx

I have assigned permissions to the Client ID using this URL:

https://contoso.sharepoint.com/sites/tempsite/_layouts/15/appinv.aspx

<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="https://contoso.sharepoint.com/sites/tempsite/"
Right="FullControl" />
</AppPermissionRequests>

I have an application, and I want to use this Client ID within the application to share folders/files with both internal and external users. Additionally, this Client ID should be able to add users to SharePoint groups created within this SharePoint site. These groups are local to the SharePoint site (not Azure AD groups or any Exchange groups, just SharePoint local groups). The users are Active Directory users synced from on-premises to Azure. Could you please guide me on how to achieve this?

If this can be achieved through Azure App Registration(Azure service principal) please guide me with Graph API permissions. The above permissions are not working.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,987 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,968 questions
{count} votes

Accepted answer
  1. Xyza Xue_MSFT 24,716 Reputation points Microsoft Vendor
    2024-09-20T07:06:11.6533333+00:00

    Hi @Roger Roger ,

    Thank you for posting in this community.

    Using the following PnP powershell to use Client ID within the application to share folders/files with both internal and external users:

    
    
    #Parameters
    $ClientID = "xx"
    $ClientSecret = "xx"
    $AdminCenterURL = "https://contoso-admin.sharepoint.com"
    $SiteURL = "https://contoso.sharepoint.com/sites/tempsite"
    $UserAccount = "[email protected]"
    $PermissionLevel = "Contribute"
     
    #Connect to PnP Online
    Connect-PnPOnline -Url $AdminCenterURL -ClientId $ClientID -ClientSecret $ClientSecret
     
    #grant access to sharepoint online site with powershell
    Set-PnPWebPermission -User $UserAccount -AddRole $PermissionLevel
    
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

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.