Is there any way to connect SharePoint Rest API with Client Credentials in C# to get site classifications? I previously used Graph API to get those collections, but I need the same using SharePoint Rest API.
IConfidentialClientApplication CCA = ConfidentialClientApplicationBuilder
.Create(c_Id).WithTenantId(t_Id).WithClientSecret(clientSecret).Build();
ClientCredentialProvider CCP = new ClientCredentialProvider(CCA);
GraphServiceClient g_Client = new GraphServiceClient(CCP);
var Sites = await g_Client.Sites.Request().GetAsync();
I used the above code to work with Graph API, How to do the same with SharePoint rest API?
SharePoint Online has blocked Azure AD App Client Secret besides certificates:
So it's necessary to create a self signed certificiate and upload for the Azure AD App:
For creating the certificate, please follow the official document, create using PowerShell:
Granting access via Azure AD App-Only
In C# code firstly, create a class named TokenProvider for example and fill with this code snippet:
Then in the Main() function call like this: