Description: Accessing SharePoint using an application context, also known as app-only can be done by using an Azure AD application. In Azure AD when doing app-only you typically use a certificate to request access: anyone having the certificate and its private key can use the app and the permissions granted to the app.
Setting up an Azure AD app for app-only access
Sign in to Azure AD account using this link. Please ensure you have administrative access.
Navigate to Azure “Active Directory” → “App registrations” → “New registration”
Fill the form as following:
Name: Auzmor SharePoint App (It can be anything)
Supported account types: Accounts in this organizational directory only.
Click on Register.
You will be redirected to Application overview page.
Copy the Client ID. This Client ID needs to be provided to Auzmor for integration.
We can use OpenSSL to generate a certificate.
Install OpenSSL:
Download and install OpenSSL from the official website.
Generate Private Key:openssl genpkey -algorithm RSA -out private-key.pem
Create Certificate Signing Request (CSR):openssl req -new -key private-key.pem -out csr.pem
Generate Self-Signed Certificate:openssl x509 -req -in csr.pem -signkey private-key.pem -out certificate.pem -days 365
Upload the certificate to Azure AD.
Go back to your app in the Azure portal.
Navigate to ”Certificates & secrets”.
Click ”Upload certificate” and upload the certificate.pem
file.
Copy Thumbprint generated after uploading the certificate.
To give the app access to SharePoint, you need to assign API permissions.
Go to “API permissions” in your app’s settings.
Click ”Add a permission” → ”Microsoft Graph” → ”Application permissions”
Select the permissions Sites.Read.All
and Sites.Selected
Click ”Add a permission” → ”SharePoint” → ”Application permissions”
Select the permissions Sites.Read.All
and Sites.Selected
Click on “Add permissions”
Click ”Grant admin consent”
Note: We require Sites.Read.All permission for listing of the sites.
Execute the below Powershell script as an Administrator.
Connect to the SharePoint tenant.
- Connect-PnPOnline -Url <Your Tenant url>
Run the below command for every site that should be accessible by the app.
- Grant-PnPAzureADAppSitePermission -AppId <Azure AD Client ID>
- DisplayName 'Auzmor Sharepoint App' -Site <Your Site Url> -Permissions FullControl
Enter the Client ID, Thumbprint, your SharePoint domain and upload Private key private-key.pem
on Auzmor to complete the integration.