SharePoint Framework (SPFx) is the go-to framework for SharePoint developers, which allows the creation of custom user interface (UI) elements, webparts, and client-side solutions. Once SPFx webparts are added to a site collection page, users gain access. However, providing permissions to external users requires some adjustments to the default settings, as outlined below.
- Modifying Sharing Settings for a Site Collection
- Granting Permission for Client-Side Assets
Modifying Sharing Settings for a Site Collection
The first step is to confirm whether external user sharing is enabled for your desired site collection. To do this, you must be a Global Administrator or SharePoint Administrator within Microsoft 365. Site owners will not have permission to change these settings. To adjust external sharing settings, follow these steps:
- Navigate to the SharePoint Admin Center (https://<your_tenant_name>-admin.sharepoint.com/) and sign in with an account holding administrative privileges.
- Search and select the site where the webpart is deployed. Click the ‘Edit‘ icon and choose ‘Sharing.’
3. In the Sharing tab, select the ‘New and existing guests‘ option the list and the click ‘Save‘.
4. Once sharing is enabled, proceed to your site collection where the webpart is deployed and assign permissions to external users.
Granting Permission for Client-Side Assets
The second step involves granting access to Client-Side Assets for external users. Follow the below steps to accomplish this:
- Open PowerShell or SharePoint Online Management Shell and connect to the SharePoint Online Administration Center using a SharePoint or Global Admin account.
$username = "email@example.com" $password = "password" $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force) Connect-SPOService -Url https://sampletenant-admin.sharepoint.com -Credential $cred
2. Once the connection is established, run the following command to enable the ‘All Users’ option in the app catalog site:
Set-SPOTenant -ShowAllUsersClaim $true
3. Visit ‘https://<your_tenant_name>.sharepoint.com/sites/AppCatalog/ClientSideAssets/AllItems.aspx‘ and navigate to permissions.
4. Select ‘Grant Permissions,’ search for and select ‘All Users,’ and click ‘Share.’
Now, the site is shared with external users. If the solution is deployed in a separate CDN, repeat the same process for the CDN site.
By following these steps, you can seamlessly extend SharePoint capabilities to external users, ensuring they can access your custom SPFx webparts and client-side assets. This allows for more inclusive and collaborative SharePoint environment.