Context
I have a working ASP.NET Core Web App, which uses Entra ID authentication:
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddInMemoryTokenCaches();
For this authentication to work I've created an Azure App registration and the configuration of the authentication contains the respective Client ID, Client secret and Tenant Id. I've added the necessary graph permissions for the Azure App registration.
I would like to call the Graph API in this web applicationfor example:
var meeting = new OnlineMeeting() { Subject = "demo meeting" };
var result = await graphClient.Me.OnlineMeetings.PostAsync(meeting);
All sample code I found is either uses device flow to get the graphClient, or uses depreciated or breaking changed authentication to create the graphClient
Question
How can I create a graphClient?
OnlineMeetings.PostAsync(meeting);, so that you can create a web mvc app in .net 8 via VS 2022 and choose Microsoft Identity platform as Authentication type, .net 7 template uses v4 SDK. then you will integrate AAD auth into your web app, then follow the code snippets shared below to addAddMicrosoftGraph, then you can get GraphServiceClient after injecting into Controller. Because you are usinggraphClient.Meso that Aad auth is necessary.