Azure Ad B2C身份验证EmailMethod通过Graph API选择

huangapple go评论61阅读模式
英文:

Azure Ad B2C Authentication EmailMethod via Graph Api select

问题

我尝试通过图形 API 调用多个属性,包括身份验证电子邮件方法。但是,当我尝试选择身份验证属性时,我总是收到一个空值。直接调用它可以正常工作,但是这种方式需要我再次调用图形 API 以获取所有其他属性。

我的调用看起来像这样。

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

这种方式,身份验证属性只显示一个空值,尽管 API 设置了UserAuthenticationMethod.ReadWrite.All。

使用以下方式可以正常工作。

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

不过,我的目标是一次性获取它,而不需要进行第二次调用。

英文:

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

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.

答案1

得分: 0

"authentication" 不是一个属性,而是一个关系,所以你不能在 .Select(...) 中指定 authentication

关系可以在 .Expand(...) 中指定,就像这样:

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

但根据文档authentication 不支持 $expand,而端点 GET /users/{user_id} 仅支持 $select

因此,无法通过一次调用来实现你的目标。

英文:

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

huangapple
  • 本文由 发表于 2023年2月8日 22:07:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75386944.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定