oauth - Microsoft Graph API 访问租户外用户的基本信息

标签 oauth ms-office exchangewebservices multi-tenant azure-active-directory

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

在 AzureAd 管理门户上,我将我的应用程序注册为 Multi-Tenancy ,并设法为租户内外的人员获取 OAuth token ,在查询身份验证代码和 token 端点时将 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: {Authorization: "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 ,

我总是以 400 错误告终: {"odata.error":{"code":"Request_BadRequest","message":{"lang":"en","value":"请求 url 中的域名无效。"}}}

知道我做错了什么吗?

最佳答案

啊啊啊!

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

当为租户内外的用户请求 token 时,相当于“common”的是...“myorganization”!

这会起作用:

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

哦,很明显是written in the doc ,但是……但是……微软!!!

关于oauth - Microsoft Graph API 访问租户外用户的基本信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30811188/

相关文章:

iOS 使用刷新的身份验证 token 处理请求

c# - 如何在 C# 中使用 MODI (Microsoft Office Document Imaging) 连续进行 OCR

Python - 在已经存在的演示文稿中编辑 Powerpoint 幻灯片内容

c# - 服务响应异常 : The specified object was not found in the store

c# - 删除 EWS EmailMessage 正文中的 HTML 部分

exchange-server - 在 Microsoft Exchange 中获取完整的用户列表

oauth - 向 Instagram auth redirect_uri 添加查询参数不起作用?

swift - Swift 中用于 OAuth 签名的 HMAC-SHA1

php - 如何以安全的方式存储我客户的 API key ?

.net - 文档查看器 C# 控件