当我使用 Microsoft Graph API 从 Azure AD B2C 获取用户时,用户注册的电子邮件地址没有出现在返回的 JSON 中。尽管 SO 中的帖子建议电子邮件地址应存在于邮件(otherMails 或 signInNames)以外的其他字段中,但接收到的 JSON 不包含任何具有预期电子邮件地址的字段。这是我为测试用户运行的请求(敏感数据被屏蔽):
GET https://graph.microsoft.com/v1.0/users/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Authorization: Bearer xxxxxxxxx
Content-Type: application/json
Run Code Online (Sandbox Code Playgroud)
响应中的 JSON 是:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"businessPhones": [],
"displayName": "unknown",
"givenName": "some",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "user",
"userPrincipalName": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@xxxxx.onmicrosoft.com",
"id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Run Code Online (Sandbox Code Playgroud)
尽管如此,当我在 Azure AD B2C 中看到用户时,电子邮件地址显示在用户列表页面的“用户名”列下:
当我查看用户的个人资料时,电子邮件地址也会显示在“用户主体名称”字段下:
电子邮件来自哪里,我如何使用 MS Graph API 获取它?
azure-active-directory azure-ad-graph-api azure-ad-b2c microsoft-graph-api