I'm attempting to build an application that can read from Microsoft Graph both as the user and as the application. For example, I need to call https://graph.microsoft.com/beta/me/calendar/events as the logged in user to get their events for the day. However, I also need the application itself to fetch all of the events for all of the conference rooms using https://graph.microsoft.com/beta/users/[email protected]/events.
I have successfully created the application in Azure AD and provided the appropriate Graph permissions to both delegates and applications as well as approved them for my tenant.
I have also used Microsoft.Identity builder configuration in Program.cs to successfully connect to my tenant and fetch my personal Graph information.
However, what I'd like to do now is be able to inject two graph connections. One for the application and one for the user. That way, when my application needs to fetch data as the application, I can call one Graph connection, and when it needs to fetch data as the user, I can call the other Graph connection.
Is it possible to configure and inject two Graph connectors, one as the user and the other as the application, in the same application?



After numerous attempts at varying ways to inject two graph clients, it turns out there's a built-in method for it.
The key method there is "WithAppOnly()", which says to fetch from Graph using the app permissions not the delegated user permissions. The only scopes I had to add were "profile user.read.all", with "profile" being delegated and "user.read.all" being an application permissions:
Edit: Found solution here: How to dependency inject Microsoft Graph client in ASP.Net Core 6 Web Api