0

I'm using Microsoft Graph SDK with .Net to retrieve a specific user's information such as email address, first name, and last name.

I've created an applications under the Azure B2C and give it the following permissions: enter image description here

Then, using a console app I've created a new GraphServiceClient and the the following code to retrieve a specific user:

Microsoft.Graph.User graphUser = await MicrosoftGraph.Users[id].Request().GetAsync();

It's returning the right user, but I couldn't retrieve any of the information I needed such as email address.

How can I ask the API the retrieve these info for me and not and empty user?

Carl Zhao
  • 8,543
  • 2
  • 11
  • 19
Elie Tebchrani
  • 309
  • 3
  • 10

3 Answers3

0

You can use Select query parameter in your code to return the set of user information

For Example,

var users = await graphClient.Users
    .Request()
    .Select("displayName,Mail")
    .GetAsync();

Please refer here to learn more.

Hari Krishna
  • 2,372
  • 2
  • 11
  • 24
0

You cannot use MS graph api for Azure B2C. B2C currently cannot call MS Graph API. You must use Azure AD Graph API to manage users in Azure AD B2C directory.

please see:here and here.

Carl Zhao
  • 8,543
  • 2
  • 11
  • 19
  • Thank you for that, but it seems that you can use MS Graph API for B2C as of [this article](https://learn.microsoft.com/en-us/azure/active-directory-b2c/manage-user-accounts-graph-api#build-user-crud-operations-by-using-the-graph-api). I did use it, and it returned users as requested, the issue is that I got only the display name of the users. Couldn't get their emails, given names, ... – Elie Tebchrani Oct 27 '20 at 07:54
0

I did find an answer for that here.

It seems that the full functionalities for B2C are only available using Microsoft Graph Beta.

Elie Tebchrani
  • 309
  • 3
  • 10