I am creating a backend Javascript service app that will access the Microsoft Graph API on a recurring schedule..
I've been able to successfully call the Graph API using the v1 endpoint, but was hoping to do the same through the v2 endpoint using the MSAL for Javascript library: https://github.com/AzureAD/microsoft-authentication-library-for-js.
I found this link, which lays out the following C# code for accomplishing what I want to do: https://blogs.msdn.microsoft.com/tsmatsuz/2016/10/07/application-permission-with-v2-endpoint-and-microsoft-graph/
using Microsoft.Identity.Client;
static void Main(string[] args)
{
// get access token including application permissions
ConfidentialClientApplication cl = new ConfidentialClientApplication(
"https://login.microsoftonline.com/testdirectory.onmicrosoft.com/v2.0",
"6abf3364-0a60-4603-8276-e9abb0d843d6",
"https://localhost/testapp02",
new ClientCredential("JfgrNM9CcW..."),
new TokenCache());
AuthenticationResult authResult = cl.AcquireTokenForClient(
new string[] { "https://graph.microsoft.com/.default" },
null).Result;
Console.WriteLine(authResult.Token);
Console.ReadLine();
}
What I'm seeing on the MSAL Javascript documentation, though, is that there is no confidentialClientApplication Class in this library.
Is there another way to submit client credentials directly and bypass the login popup altogether? Or, are there alternatives to this library I could consider?