如何从 Graph Explorer 查询另一个 Azure Active Directory 租户

How to query another Azure Active Directory tenant from Graph Explorer

我正在使用 Azure Graph API 资源管理器。我想查询租户中的应用程序列表。我是 tenant_x 中的用户(最初创建用户的位置)以及 tenant_y 中的管理员(稍后与我的用户一起创建)。我知道当我登录时我直接进入原始租户(所以 tenant_x)因此 Graph Explorer 不允许我查询 tenant_y。因此,作为 tenant_y 的管理员,我在 tenant_y 中添加了一个新用户。我现在使用该用户登录,但仍然无法查询 tenant_y 中的应用程序。那么如何查询tenant_y中的应用呢?有办法吗?谢谢。

我正在调用的 API(新用户登录)首先检索所有应用程序:

https://graph.microsoft.com/beta/applications

响应是:

{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#applications",
"value": []
}

当然我在那个租户中有应用程序。

根据我们的沟通,您已使用个人帐户作为 tenant_y 的访客来查询 tenant_y 中的应用程序列表。

遗憾的是,Microsoft Graph Explorer 不会将您的个人帐户识别为来宾用户。它仍然会将其视为个人帐户。

因此它将查询个人帐户的应用程序列表而不是 tenant_y。

所以现在你有两个选择:

  • 按照 add a new user 在 tenant_y 中创建一个新用户,然后 然后使用这个新用户登录Microsoft Graph Explorer 进行查询 应用程序列表。
  • 实施 Get access on behalf of a user 并确保您 调用 {your tenant} 端点而不是 common 端点 请求访问令牌。你应该使用另一个工具(对于 例如 Postman) 而不是 Microsoft Graph 资源管理器。

更新:

你可以这样修改Microsoft Graph Explorer中的权限:

在 Microsoft Graph 资源管理器中单击您用户名下的 "modify permissions" 并检查 Directory.Read.All 权限。

Graph Explorer today does not support signing in to the tenanted 端点。租户端点按以下格式使用

https://login.microsoftonline.com/{tenantId}/V2.0

一旦您的 tenant_x 用户帐户成为 guest user in tenant_y, to effectively query tenant_y using your guest user account, an app (like Graph explorer) has to sign you in the other tenant. Instead Graph Explorer uses the /Common 端点,它将始终让您登录到您的家庭租户 (tenant_x)。

唯一可用的解决方法是快速开发 application 并登录到您选择的租户和其中的 运行 Api。

图浏览器是一种帮助开发人员发现和了解图 Api 的工具,因此可能会避免引入过多的复杂性。但在他们的 Github repo.

处要求此功能并没有坏处

今天,如果您像这样传递租户查询字符串参数,这是可能的:

https://developer.microsoft.com/en-us/graph/graph-explorer?tenant=mydomainname.onmicrosoft.com

请注意,在使用租户查询字符串转到此 URL 之前,您需要注销。它会要求你重新登录。登录后,您可以针对您有权访问的其他租户(不是您最初创建帐户的家庭租户)发出查询。

如果您在 运行 特定查询时收到 401,请确保您在 "Modify permissions" 选项卡上授予所需的权限,并单击每个所需权限中的 Consent 按钮。之后您的查询应该 return 200 成功结果。