gpt4 book ai didi

azure - 为什么不同的 Microsoft Graph API 返回不同的数据

转载 作者:行者123 更新时间:2023-12-03 01:36:13 25 4
gpt4 key购买 nike

我正在使用Microsoft Graph Users API根据我们的 ActiveDirectory 验证用户名或电子邮件地址列表。名称搜索:

https://graph.microsoft.com/v1.0/me/people/?$search=john.smith

返回附加数据,例如 officeLocationjobTitle。但如果我使用电子邮件搜索:

https://graph.microsoft.com/v1.0/users/[email protected]

这些附加字段为空。我已在 Azure 中启用这些 API 权限:

  • 人物.阅读
  • 用户.阅读
  • User.ReadBasic.All
  • 电子邮件

我需要额外的权限才能获取相同的数据吗?

更新:我在 https://developer.microsoft.com/en-us/graph/graph-explorer 中尝试过此操作如下所示,它可以工作,但 Graph Explorer 默认带有这些权限,无法禁用:

  • 日历.ReadWrite
  • 联系人.ReadWrite
  • 目录.读取.全部
  • 文件.ReadWrite.All
  • Mail.ReadWrite
  • Notes.ReadWrite.All
  • openid
  • People.Read
  • Sites.ReadWrite.All
  • 任务.ReadWrite
  • User.ReadBasic.All
  • 用户.ReadWrite

更新 2:我使用的是 Python 3.7,因此我从 https://github.com/microsoftgraph/python-sample-console-app/blob/master/helpers.py#L25 借用了 device_flow_session() 。我从https://graph.microsoft.com/me/people/取回的数据?$search=John.Smith 看起来像:

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")/people",
"value": [{
"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"displayName": "John Smith",
"givenName": "John",
"surname": "Smith",
"birthday": "",
"personNotes": "",
"isFavorite": False,
"jobTitle": "Software Engineer",
"companyName": "Company",
"yomiCompany": "",
"department": "Fish",
"officeLocation": "London",
"profession": "",
"userPrincipalName": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="13597c7b7d3d407e7a677b53707c7e63727d6a3d707c7e" rel="noreferrer noopener nofollow">[email protected]</a>",
"imAddress": "sip:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="de94b1b6b0f08db3b7aab69ebdb1b3aebfb0a7f0bdb1b3" rel="noreferrer noopener nofollow">[email protected]</a>",
"scoredEmailAddresses": [{
"address": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8bc1e4e3e5a5d8e6e2ffe3cbe8e4e6fbeae5f2a5e8e4e6" rel="noreferrer noopener nofollow">[email protected]</a>",
"relevanceScore": -6.0991198031917175,
"selectionLikelihood": "notSpecified"
}
],
"phones": [],
"postalAddresses": [],
"websites": [],
"personType": {
"class": "Person",
"subclass": "OrganizationUser"
}
}
]
}

而数据来自https://graph.microsoft.com/users/[email protected]是:

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"businessPhones": [],
"displayName": "John Smith",
"givenName": "John",
"jobTitle": None,
"mail": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fab0959294d4a997938e92ba9995978a9b9483d4999597" rel="noreferrer noopener nofollow">[email protected]</a>",
"mobilePhone": None,
"officeLocation": None,
"preferredLanguage": None,
"surname": "Smith",
"userPrincipalName": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f05202721611c22263b270f2c20223f2e2136612c2022" rel="noreferrer noopener nofollow">[email protected]</a>",
"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}

最佳答案

根据我的测试,我发现这两个API获取的信息来自不同的地方。

/me/people 返回的

“officeLocation”似乎在 SharePoint 中维护。您可以登录https://apc.delve.office.com/?u=3df5295a-e4b1-46fe-8969-e715ccd11077&v=editprofile检查一下。

/me/users/{id | 返回的“officeLocation” userPrincipalName} 在 Azure AD 中维护。因此您可以在 Azure AD -> 用户中检查它。

更新 Azure AD 中的“Office”后,我使用两个终结点进行查询。但他们给了我两个不同的结果。一个 (/me/people) 是旧的,另一个 (/users/{id | userPrincipalName}) 是新的。也许这需要一些时间来同步。或者它们可能不会同步。

我还在 Microsoft Graph Explorer 中测试了它。而且“officeLocation”也不同。所以我不确定为什么 Microsoft Graph Explorer 适合您。但你可以按照我的想法来挖掘它。

希望我的发现对您有所帮助。

关于azure - 为什么不同的 Microsoft Graph API 返回不同的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57702927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com