You can obtain the SharePoint AccessToken within your Salesforce Apex class.
Please review the provided code snippet below or visit my YouTube tutorial:
// Here is the code
public class SharePointAccessToken {
@AuraEnabled
public static void getAccessToken(){
String bodyRequest;
HttpRequest request = new HttpRequest();
bodyRequest = 'grant_type=client_credentials';
bodyRequest += '&client_id=ee232e2f-c11a-4a56-98df-e24d3f600571@4b529a0e-f8fe-4269-b994-febc3d20f8cc';
//bodyRequest += '&client_secret=xMM/qKtAG0UOL8rAJ/OKJ7j+Fz5acczPDsr5KFVm58k=';
bodyRequest += '&client_secret=xMM%2fqKtAG0UOL8rAJ%2fOKJ7j%2BFz5acczPDsr5KFVm58k%3D';
bodyRequest += '&resource=00000003-0000-0ff1-ce00-000000000000/v2218.sharepoint.com@4b529a0e-f8fe-4269-b994-febc3d20f8cc';
/*
Note: In the client_secret, replace the following:
"+" ==> "%2B",
"=" ==> "%3D",
"/" ==> "%2f"
*/
request.setMethod('GET');
request.setBody(bodyRequest);
request.setEndpoint('https://accounts.accesscontrol.windows.net/4b529a0e-f8fe-4269-b994-febc3d20f8cc/tokens/oAuth/2');
Http https = new Http();
HttpResponse response = https.send(request);
System.debug('Status Code ' + response.getStatusCode());
System.debug('Body ' + response.getBody());
}
}