简体   繁体   English

如何将Web应用程序与Office 365的EWS托管API结合使用?

[英]How can I use web app with EWS managed API for office 365?

With c#; 用c#; I am able to use access_token generated with native app to request EWS managed api for office 365. I am trying to use access_token generated with web app . 我能够使用通过本机应用程序生成的access_token来请求Office 365的EWS托管api。我正在尝试使用通过Web应用程序生成的access_token。 This is failing at service.AutodiscoverUrl('mailid', delegate(string url){return true}) and getting error ' The Autodiscover service couldn't be located. 这在service.AutodiscoverUrl('mailid', delegate(string url){return true})失败,并出现错误' 无法找到Autodiscover服务。 '. '。

I am using following code to generate access_token using web app. 我正在使用以下代码使用Web应用程序生成access_token。

string authority = "https://login.windows.net/common/oauth2/authorize";
string serverName = "https://outlook.office365.com";
AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);
ClientCredential credential = new ClientCredential("Web app client id", "Web app secret key");
AuthenticationResult authenticationResult = authenticationContext.AcquireToken(serverName, credential);
authenticationResult.AccessToken; // read access_token here.

Can I use Web App with EWS managed API for office 365 or it is limited t native app? 我可以将Web App与EWS托管API一起用于Office 365,还是仅限本机应用程序?

EWS supports Oauth Authentcation but Autodiscover doesn't so EWS支持Oauth身份验证,但自动发现不支持

service.AutodiscoverUrl('mailid', delegate(string url){return true})

Wont work however if you have set the permission correctly in Azure any EWS request should work okay. 但是,如果在Azure中正确设置了权限,则任何EWS请求都应该可以正常工作。 Because there is only one EWS endpoint in Office365 you don't need to use Auto-discover just use 由于Office365中只有一个EWS终结点,因此您无需使用自动发现,只需使用

service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

eg http://www.jeremythake.com/2014/08/using-the-exchange-online-ews-api-with-office-365-api-via-azure-ad/ 例如http://www.jeremythake.com/2014/08/using-the-exchange-online-ews-api-with-office-365-api-via-azure-ad/

Cheers Glen 干杯格伦

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

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