在多租户应用程序中如何在Azure门户中注册应用程序的地方查看租户数据?

时间:2019-08-17 16:48:13

标签: azure azure-active-directory microsoft-graph sharepoint-online

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

  • 租户1:abc.sharepoint.com
  • 租户2:xyz.sharepoint.com

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

  • 身份验证正常
  • 当我与租户1'abc.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" } } }

其中一个已与另一租户的用户进行了身份验证。如何查看申请已注册的信息?

1 个答案:

答案 0 :(得分:0)

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

如果要这样做,您需要:

  1. 将Tenant 2'xyz.sharepoint.com'的用户作为访客添加到Tenant中 1个“ abc.sharepoint.com”。参见Quickstart: Add guest users to your directory in the Azure portal
  2. 使用租户1中的管理员帐户对在租户2中的Azure AD中注册的应用进行管理同意。只需要打开浏览器并向
  3. 发出请求即可。
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的管理员帐户登录,然后单击“接受”。Accept screenshot
  2. 获取访问令牌并使用它来访问租户1'abc.sharepoint.com'。