截至今天,文档建议使用Microsoft Graph而不是Azure AD Graph API来访问Azure AD / B2C资源 .
之前,使用Azure AD Graph API,我们可以使用像https://graph.windows.net/[tenant]/users/1a2a9c4d-fc59-4fd9-ad14-b72b549cdf6a?api-version=2013-11-08这样的查询
响应包括Azure B2C自定义属性(在Azure门户上创建)
{
"odata.metadata": "https://graph.windows.net/<tenant>/$metadata#directoryObjects/Microsoft.DirectoryServices.User",
"value": [
{
"objectId": "00000eab-603a-4de2-9d25-d3821e7d6583",
...
"extension_3a4189d71ad149c6ab5e65ac45bd6add_MyAttribute1": "something"
}
]
}
使用Graph API不会发生这种情况,只返回一些"basic"属性https://graph.microsoft.com/v1.0/users/00000eab-603a-4de2-9d25-d3821e7d6583
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "00000eab-603a-4de2-9d25-d3821e7d6583",
...
}
还尝试显式选择属性,但不返回扩展值
... graph.microsoft.com/v1.0/users/00000eab-603a-4de2-9d25-d3821e7d6583/?$select=id,extension_3a4189d71ad149c6ab5e65ac45bd6add_MyAttribute1
我们如何使用Graph API读取Azure B2C自定义属性?
2 回答
请参阅此SO帖子:As of today, we recommend that you use the Azure Active Directory Graph API https://graph.windows.net以访问和管理您的B2C租户
返回自定义属性:
Request
Response
来源:这是来自sample app: B2C-GraphAPI-DotNet
Lookup Extension Guid 通过Azure门户
以上内容适用于内置策略 .