如何将Web应用程序与EWS托管API一起用于Office 365? [英] How can I use web app with EWS managed API for office 365?

查看:116
本文介绍了如何将Web应用程序与EWS托管API一起用于Office 365?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用c#; 我可以使用通过本地应用生成的access_token来请求Office 365的EWS托管api. 我正在尝试使用通过网络应用生成的access_token.这在service.AutodiscoverUrl('mailid', delegate(string url){return true})处失败,并显示错误"找不到自动发现服务.".

With 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. This is failing at service.AutodiscoverUrl('mailid', delegate(string url){return true}) and getting error 'The Autodiscover service couldn't be located.'.

我正在使用以下代码通过网络应用生成access_token.

I am using following code to generate access_token using web app.

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.

我可以将Web App与用于Office 365的EWS托管API一起使用,还是仅限本机应用程序?

Can I use Web App with EWS managed API for office 365 or it is limited t native app?

推荐答案

EWS支持Oauth身份验证,但自动发现不支持

EWS supports Oauth Authentcation but Autodiscover doesn't so

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

但是,如果您在Azure中正确设置了权限,则任何EWS请求都应该可以正常工作.由于Office365中只有一个EWS终结点,因此您无需使用自动发现,只需使用

Wont work however if you have set the permission correctly in Azure any EWS request should work okay. Because there is only one EWS endpoint in Office365 you don't need to use Auto-discover just use

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

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

欢呼 格伦

这篇关于如何将Web应用程序与EWS托管API一起用于Office 365?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆