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 = "user@contoso.com"
$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.