...
Open the Microsoft Azure Admin Portal.
Go to Identity > Applications > App registrations.
Click New registration.
Give the application a name. Select Accounts in this organizational directory only. Click Register.
Go to Manage > Certificates & secrets.
Click Client secrets > New client secret.
Give the client secret a description and an expiration date. Click Add.
Make sure to copy the value of the client secret now as it is only visible immediately after creation.
Go to Manage > API permissions.
Click Add a permission.
Select Microsoft Graph > Application permissions > Sites > Sites.Selected. Click Add permissions.
Ask an administrator to grant their content consent on the permission or click Grant admin consent if you are an administrator.
Go to Overview.
Copy the Application (client) ID and the Directory (tenant) ID.
...