MS Graph API 无法从 Azure AD B2C 返回用户的电子邮件地址。

问题描述 投票:0回答:1

当我使用 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中看到该用户时,电子邮件地址显示在用户列表页的 "用户名 "栏下。

enter image description here

而当我查看用户的资料时,邮件地址也显示在 "用户主名 "栏下。

enter image description here

邮件从哪里来,如何使用MS Graph API获取?

azure-active-directory microsoft-graph azure-ad-b2c azure-ad-graph-api
1个回答
2
投票

你可以使用Beta端点从身份集合中获取用户名。

查询

https://graph.microsoft.com/beta/users/userid?select=identities

请浏览 物品

© www.soinside.com 2019 - 2024. All rights reserved.