简体   繁体   English

如何为Exchange 2016配置混合模式以使OAuth2客户端凭据流与Microsoft Graph API一起使用

[英]How to configure Hybrid mode for Exchange 2016 to have OAuth2 Client Credentials flow working with Microsoft Graph API

I configured Hybrid mode on a customer's Exchange 2016. Now users' mailboxes are exposed on the Microsoft Graph API using the individual consent flow (authorization code Oauth2 flow). 我在客户的Exchange 2016上配置了混合模式。现在,使用个人同意流(授权代码Oauth2流)在Microsoft Graph API上公开用户的邮箱。

Getting an admin consent with a client credentials flow seems to work : a token is retreived on the Microsoft endpoint, the payload is correct (right scopes), but it triggers an "unknown error" when using it to get a mailbox content through the Microsoft Graph API. 通过客户端凭据流获得管理员同意似乎有效:在Microsoft端点上检索到令牌,有效负载是正确的(正确的范围),但在使用它通过Microsoft获取邮箱内容时会触发“未知错误”图API。 The same token does work to get directory information (meaning the token is valid at some point). 相同的标记确实可以获取目录信息(意味着令牌在某些时候有效)。

Is Hybrid mode compatible with the Client Credentials flow ? 混合模式是否与Client Credentials流程兼容? Is there any parameters to configure in Exchange to enable this flow ? 是否有任何参数要在Exchange中配置以启用此流程?

I stumbled upon the same issue some time ago. 我不久前偶然发现了同样的问题。 Just let it slide, as I thought it was some wrong configuration on the Exchange side. 只是让它滑动,因为我认为这是Exchange方面的一些错误配置。

If you inspect both tokens you'll see that the sid is missing on the Client Credentials token, I think exchange needs some sort of on-premise user id inside the token to work. 如果您检查两个令牌,您将看到客户端凭据令牌上缺少sid,我认为交换需要令牌中的某种内部部署用户ID才能工作。 I'm not sure if this flow is supported since I cannot find anything about this topic on their documentation websites. 我不确定是否支持此流程,因为我在他们的文档网站上找不到关于此主题的任何内容。

I just found a totally related question, check out https://stackoverflow.com/a/56108226/639153 for a complete answer. 我刚刚找到一个完全相关的问题,请查看https://stackoverflow.com/a/56108226/639153以获得完整的答案。

The issue is actually somewhere else - Exchange doesn't seem to support client_credentials flow. 问题实际上是在其他地方 - Exchange似乎不支持client_credentials流。 You can, however force it via following PowerShell (make sure to restart your IIS after applying): 您可以通过以下PowerShell强制它(确保在应用后重新启动IIS):

$apps = Get-PartnerApplication
# Microsoft Graph is 2nd item in the array, if you are unsure, list the items by calling $apps first
$apps[1] | Set-PartnerApplication -AppOnlyPermissions $apps[1].ActAsPermissions

The full explanation can be found here: https://blog.thenetw.org/2019/05/13/using-client_credentials-with-microsoft-graph-in-hybrid-exchange-setup/ 完整的解释可以在这里找到: https//blog.thenetw.org/2019/05/13/using-client_credentials-with-microsoft-graph-in-hybrid-exchange-setup/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM