英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论