【发布时间】:2021-06-11 03:16:59
【问题描述】:
在向 Azure B2C Graph API 查询以检索特定用户时,我注意到有时不会返回任何结果,但会从 Graph API 服务器返回 HTTP 200 代码。每次我们需要调用 Graph API 时,我们的服务器都会创建一个 Graph API 令牌(将来会处理,但这可能是我遇到以下问题的原因)。
这些问题大多发生在我们用 Python 编写的集成测试期间。
首先,我们在 Azure B2C 中创建用户:
Inserting test user with data: {
"accountEnabled":true,
"displayName":"Patricia Robles",
"mailNickname":"PatriciaRobles",
"extension_<id>_organizationId":"b5468371-54e7-41d3-8dc4-904779417ce2",
"extension_<id>_organizationName":"My Organization",
"extension_<id>_username":"PatriciaRobles",
"givenName":"Patricia",
"surname":"Robles",
"userPrincipalName":"PatriciaRobles@testb2c.onmicrosoft.com",
"passwordProfile":{
"password":"He#02021"
}
}
Created in Graph API: {
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id":"5e2ae56c-4493-451f-be26-de51e05475c5",
"businessPhones":[
],
"displayName":"Patricia Robles",
"givenName":"Patricia",
"jobTitle":"None",
"mail":"None",
"mobilePhone":"None",
"officeLocation":"None",
"preferredLanguage":"None",
"surname":"Robles",
"userPrincipalName":"PatriciaRobles@testb2c.onmicrosoft.com"
}
所以看起来它实际上是在 Azure B2C 中创建了用户。请注意,我实际上更改了实际运行时的值以防止泄露敏感数据。
现在,作为测试期间的健全性检查,我想查询组织中的所有用户:
https://graph.microsoft.com/v1.0/users?$select=identities,givenName,id,surname&$filter=extension_<id>_organizationId eq 'b5468371-54e7-41d3-8dc4-904779417ce2'
Returned for Graph API: {'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#users(identities,givenName,id,surname)', "value":[
{
"givenName":"Patricia",
"id":"5e2ae56c-4493-451f-be26-de51e05475c5",
"surname":"Robles",
"identities":[
{
"signInType":"userPrincipalName",
"issuer":"testb2c.onmicrosoft.com",
"issuerAssignedId":"PatriciaRobles@testb2c.onmicrosoft.com"
}
]
},
{
"givenName":"Ruby",
"id":"a7b2d2fe-3176-49bc-9775-691195ed9002",
"surname":"Woodard",
"identities":[
{
"signInType":"userPrincipalName",
"issuer":"testb2c.onmicrosoft.com",
"issuerAssignedId":"RubyWoodard@testb2c.onmicrosoft.com"
}
]
},
{
"givenName":"Helen",
"id":"d97201c8-e561-4b83-aa75-441ccc069a18",
"surname":"Charles",
"identities":[
{
"signInType":"userPrincipalName",
"issuer":"testb2c.onmicrosoft.com",
"issuerAssignedId":"HelenCharles@testb2c.onmicrosoft.com"
}
]
}
]
}
用户肯定存在于 Azure B2C 中。所以我们绝对应该能够查询那个单独的用户,对吧?
嗯,不完全是:
https://graph.microsoft.com/v1.0/users?$select=identities,givenName,id,surname&$filter=extension_5d0e560b4ba9481d97b55226dd4c411a_organizationId eq 'b5468371-54e7-41d3-8dc4-904779417ce2' and id eq '5e2ae56c-4493-451f-be26-de51e05475c5'
Returned for Graph API: {'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#users(identities,givenName,id,surname)', 'value': []}
Retrieved from Graph API: {}
所以现在,没有用户通过 Graph API 从 Azure B2C 返回。
为什么会发生这种情况?
【问题讨论】:
标签: azure azure-active-directory azure-ad-b2c azure-ad-graph-api