当我使用 Microsoft Graph API 从 Azure AD B2C 获取用户时,用户注册的电子邮件地址没有出现在返回的 JSON 中。虽然SO中的一些帖子建议电子邮件地址应该存在于Mail以外的其他字段中(otherMails或signInNames),但接收到的JSON中并不包含任何具有预期电子邮件地址的字段。下面是我为一个测试用户运行的请求(敏感数据被屏蔽)。
GET https://graph.microsoft.com/v1.0/users/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Authorization: Bearer xxxxxxxxx
Content-Type: application/json
响应中的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": "[email protected]",
"id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
尽管如此,当我在Azure AD B2C中看到该用户时,电子邮件地址显示在用户列表页的 "用户名 "栏下。
而当我查看用户的资料时,邮件地址也显示在 "用户主名 "栏下。
邮件从哪里来,如何使用MS Graph API获取?