I am learning / experimenting with Azure Active Directory B2C (AADB2C). I have created a web application that can sign-in or sign-up users (not using custom user flows) with OpenID Connect.
Once a user has signed in, I would like to make a call to Microsoft Graph to get information about the signed in user.
According to the docs, I initialize a client credential auth provider as follows:
var scopes = new[] { "https://graph.microsoft.com/.default" };
var clientSecretCredential = new ClientSecretCredential(config.TenantId, config.AppId, config.ClientSecret);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
I then try to make a request, as follows:
var user = await graphClient.Me.Request().GetAsync();
The above results in the exception:
Code: BadRequest
Message: /me request is only valid with delegated authentication flow.
When I try the following:
var user = await graphClient.Users[ '' ].Request().GetAsync();
The above results in the exception:
Code: Authorization_RequestDenied
Message: Insufficient privileges to complete the operation.
Many of the examples in the MS documentation state that the "User.Read" permission must be granted, but when using the Azure Portal the "User.Read" permission is not found, below is a screen snapshot of the Request API Permissions blade within the Azure portal - I am still not clear on the Note (highlighted in the image below).
When I do try to enter the "User.Read" permission, the following is displayed:
I also found this tutorial regarding how to Register a Microsoft Graph application, but it seems to be geared to administrators who want to access the graph, not "regular" signed-in users per se.
My question - Is there any working example that illustrates how (after a user is signed in) to read the users information from Microsoft Graph?