首页 > 解决方案 > 在多租户应用程序中如何检查应用程序在 Azure 门户中注册的租户数据?

问题描述

我有 2 个来自不同组织(租户)的 SharePoint 网站:

已在 Tenan 1 'abc.sharepoint.com' 的 Azure 门户上注册并授予应用程序的必要权限,以便租户 2 用户可以访问它:'xyz.sharepoint.com'

我想要的是通过租户 2 'xyz.sharepoint.com' 的用户进行身份验证,您可以查阅 sharepoint 的数据,例如:

当我提出请求时:

  1. https://graph.microsoft.com/v1.0/sites/roothttps://graph.microsoft.com/v1.0/sites/xyz.sharepoint.com

    它令人满意地返回信息,因为它咨询了“xyz.sharepoint.com”的站点,因为用户来自该租户

...但是当我咨询指定租户“abc.sharepoint.com”时

  1. https://graph.microsoft.com/v1.0/sites/abc.sharepoint.com

    返回以下错误:

    { "error": { "code": "invalidRequest", "message": "Invalid hostname for this tenancy", "innerError": { "request-id": "c0a8fa51-245b-4d1e-bf0b-5f32b6c0eb26", "date": "2019-08-17T16:27:57" } } }

一个与另一个租户的用户进行身份验证。如何查看应用程序已注册的信息?

标签: azureazure-active-directorymicrosoft-graph-apisharepoint-online

解决方案


我们不能使用从一个租户获得的访问令牌来访问另一个租户。

如果你想这样做,你需要:

  1. 将租户 2 'xyz.sharepoint.com' 的用户作为访客添加到租户 1 'abc.sharepoint.com'。请参阅快速入门:将来宾用户添加到 Azure 门户中的目录
  2. 使用租户 1 的管理员帐户对租户 2 的 Azure AD 中注册的应用程序进行管理员同意。只需打开浏览器并发出请求
https://login.microsoftonline.com/common/oauth2/authorize?client_id={client id of the app registered in Azure AD of Tenant 2}&response_type=code&redirect_uri={reply url of the app registered in Azure AD of Tenant 2}&nonce=1234&resource=https://graph.microsoft.com&prompt=admin_consent
  1. 使用租户 1 的管理员帐户登录,然后单击“接受”。接受截图
  2. 获取访问令牌并使用它来访问租户 1 'abc.sharepoint.com'。

推荐阅读