How to acquire token from User.Identity displayed in e.g. NETCoreMVCwithMSGraph template ? #62
-
Hello, I can see that the login is successful in the Graph MVC project template('NETCoreMVCwithMSGraph') and the email in the nav bar is shown based on the 'User.Identity?.Name'-property, the thing that I don't understand is: How do I use the User object to initiate the GraphServiceClient object which will let me to gather more information about .Me ? All I can see is that User.Identity consists of several properties, do I need to use .Claims collections ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @magicalKhachapuri, Microsoft Graph is called during the Microsoft Identity Platform connected service integration and Microsoft Graph is already added in the Program.cs with the following code: All you need is to include GraphServiceClient in the Controller, so that you can make many other Graph calls moving forward. |
Beta Was this translation helpful? Give feedback.
Hi @magicalKhachapuri, Microsoft Graph is called during the Microsoft Identity Platform connected service integration and Microsoft Graph is already added in the Program.cs with the following code:
.AddMicrosoftGraph(builder.Configuration.GetSection("MicrosoftGraph"))
All you need is to include GraphServiceClient in the Controller, so that you can make many other Graph calls moving forward.
There is a brief explanation in this sample you may go through for your upcoming Graph calls: https://learn.microsoft.com/en-us/samples/azure-samples/active-directory-aspnetcore-webapp-openidconnect-v2/active-directory-aspnetcore-webapp-openidconnect-v2/#process-the-cae-challenge-from-microsoft-graph