Outlook web add-in autentication failure for on-premise exchange

杀马特。学长 韩版系。学妹 提交于 2019-12-08 13:27:29

问题


I use Office.js's getCallbackTokenAsync to load the token to pass to the backend.

In the backend, I use EWS to retrieve the email data. Here is how I perform the authentication.

ExchangeService service = new ExchangeService();
service.Url = new Uri(ewsUrl); //retrieved from getCallbackTokenAsync
service.Credentials = new OAuthCredentials(ewsToken);// retrieved from getCallbackTokenAsync

It works well in exchange online enviroment. However when tested in on-premise exchange server, I got this authentication error:

Error Message: The remote server returned an error: (401) Unauthorized.
Stack Trace:   at System.Net.HttpWebRequest.GetResponse() at Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse() at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)

I then found this doc says the Oauth2 authentication is only for exchange online. I guess I need to use this NTLM (Exchange on-premises only).

The major reason I use EWS instead of Graph or Rest is it supports on-premise server more naturally. So should I change the authentication here? I certainly do not want to ask user for username and password.

来源:https://stackoverflow.com/questions/53331863/outlook-web-add-in-autentication-failure-for-on-premise-exchange

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!