Microsoft Graph API 正在访问租户之外的用户的基本信息

Microsoft Graph API Accessing basic info of a user that is outside tenancy

我正在开发一个 multi-tenant 网络应用程序来管理用户的邮件、联系人和日历。

在 AzureAd 管理门户上,我将我的应用程序注册为 multi-tenant,我设法为租户内外的人获取 OAuth 令牌,在查询身份验证时将 tennantId 替换为 "common"代码和令牌端点。

现在,我想访问登录并同意授予我的应用程序权限的人的日历、邮件和联系人信息。

我开始很简单,通过查询用户的基本用户信息 inside tenancy 像这样:

获取https://graph.windows.net/-tennantId-/me?api-version=2013-11-08 或者 获取 https://graph.windows.net/-tennantId-/users/myAdress@company.com?api-version=2013-11-08 {headers:{授权:"Bearer -accessToken-"}}

有效!

现在,我如何才能访问我的租户以外的用户的信息?我试过了

获取https://graph.windows.net/-tennantId-/me?api-version=2013-11-08

获取https://graph.windows.net/-tennantId-/users/address@outside.com?api-version=2013-11-08

获取https://graph.windows.net/common/me?api-version=2013-11-08

获取 https://graph.windows.net/common/users/address@outside.com?api-version=2013-11-08

我总是 end-up 出现 400 错误: {"odata.error":{"code":"Request_BadRequest","message":{"lang":"en","value":"Invalid domain name in the request url." }}}

知道我做错了什么吗?

啊啊啊!

如果您使用 OAuth 开发多租户应用程序,请在与 Graph 对话时忘记使用您的租户 ID API!

当为租户内外的用户请求令牌时,等同于 "common" 是... "myorganization"!

这会起作用:

https://graph.windows.net/myorganisation/me?api-version=2013-11-08

哦,很明显是 written in the doc,但是...但是...MICROSOOOOOFT!!!