简体   繁体   English

Exchange Web Service API和401未经授权但成功

[英]Exchange Web Service API and 401 unauthorised but succeeding

Connecting to Exchange Web Services for Office 365 reports multiple dependency failures in Application Insights. 连接到Office 365的Exchange Web服务会在Application Insights中报告多个依赖项失败。

The code below actually works and does return folder and message results. 下面的代码实际上有效,并且确实返回文件夹和消息结果。 But we're constantly seeing huge numbers of failures reported by Application Insights when we hit the endpoints. 但是,当我们遇到端点时,我们经常看到Application Insights报告大量失败。

在此处输入图片说明

service = new ExchangeService(ExchangeVersion.Exchange2013_SP1, TimeZoneInfo.Local);
service.Credentials = new WebCredentials(account, password, "domain_foo");
service.Url = new Uri(@"https://outlook.office365.com/EWS/Exchange.asmx");

I would expect this to just not fail, but the fact that we get mailbox data back AND see dependency call failures is just bizarre. 我希望这不会失败,但是我们将邮箱数据取回并看到依赖项调用失败的事实真是奇怪。 Application Insights doesn't allow us to drill down further to see what the problem was, but we're seeing a failure rate of 50/s to 75/s Application Insights不允许我们进一步深入了解问题所在,但是看到的故障率是50 / s至75 / s

If the request are not failing then 401's are normal during credential negotiation eg the first request will return a 401 as a Challenge with the headers telling the requester what authentication is available on the server see https://blogs.msdn.microsoft.com/benjaminperkins/2011/09/14/integrated-windows-authentication-with-negotiate/ 如果请求没有失败,则在凭据协商期间401正常,例如,第一个请求将返回401作为质询,其标头告诉请求者服务器上可用的身份验证,请参见https://blogs.msdn.microsoft.com/ benjaminperkins / 2011/09/14 / integrated-windows-authentication-withnegotiate /

If you using Office365 then don't use Basic authentication its going away next year https://techcommunity.microsoft.com/t5/Exchange-Team-Blog/Upcoming-changes-to-Exchange-Web-Services-EWS-API-for-Office-365/ba-p/608055 you should look to use OAuth instead or even look at using the Graph if you can. 如果您使用的是Office365,则不要使用基本身份验证,它明年将消失https://techcommunity.microsoft.com/t5/Exchange-Team-Blog/Upcoming-changes-to-Exchange-Web-Services-EWS-API-对于Office-365 / ba-p / 608055 ,如果可以的话,您应该使用OAuth代替,甚至使用Graph。

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

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