As you may be aware the legacy method fot granting "apps" access to sharepoint v Graph API is deprecared https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-ins-and-azure-acs-retirements-faq
This repos gives scripts for an updated process using Entra ID and Powershell.
You must have created an "app registration" and have the following parmaeters:
- Client ID
- Client Secret
- Hostname. The sharePoint Hostname, Eg prodata365.sharepoint.com
- Path . The Paht to the Site. Eg /sites/Test
- role. The permisions needed. generally either "write" or "read"
Powershell IDE (Either VS Code or Powershell IDE)
MS Graph Powershell Module installed: Install-Module Microsoft.Graph
We assume that this step is probably already done if you are not sure how to add an app registration and grant o MS Graph permissions, there is a deck in repos here https://github.com/ProdataSQL/sharepoint-sites-selected-setup/blob/main/SharePoint%20SP%20Creation.pptx
Using the sample script below populate the parameters for Client ID, Client Secret, Sharepoint Hostname, Path and required rols (read or write) https://github.com/ProdataSQL/sharepoint-sites-selected-setup/blob/main/02_SharePoint-Permissions.ps1
When this runs, you will need to follow the instructiont to goto a web browser and validate using a device token
Then it will add permissons and display confirmation like below:
Now that we have set permissions we can test access by using te script below after setting paramaters: ClientId, TenantId, Hostname, Path https://github.com/ProdataSQL/sharepoint-sites-selected-setup/blob/main/03_SharePoint-Test.ps1
This will prompt for the "Client Secret" and then test access to the SharePoint Site by listing directories.

