Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Azure Ad B2C Authentication EmailMethod via Graph Api select

I’m trying to call multiple attributes via the graph api including the authentication email methods.
However when i try to select the authentication attribute, i always receive a null value.
Calling it directly works fine, however that way i need to call the graph api a second time to get all other attributes.

My Call looks something like this.

await _graphClient.Users[userId].Request()
        .Select($"displayName,authentication,otherMails,identities).GetAsync();

This way the authentication attributes just shows a null value,
even though the UserAuthenticationMethod.ReadWrite.All is set for the api

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Using this works just fine

await _graphClient.Users[userId].Authentication
        .EmailMethods["3ddfcfc8-9383-446f-83cc-3ab9be4be18f"].Request().GetAsync();

however my goal would be to get it in one fell swoop, without the need for a second call.

>Solution :

authentication is not a property but a relationship, so you can’t specify authentication in .Select(...).

Relationships can be specified in .Expand(...) like

await _graphClient.Users[userId].Request()
    .Select($"displayName,otherMails,identities")
    .Expand("authentication").GetAsync();

But according to the documentation authentication doesn’t support $expand and the endpoint GET /users/{user_id} supports only $select.

So it’s not possible to achieve your goal by one call

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading