2016-04-28 42 views
0

用c#; 我能够使用具有的access_token本地应用产生的请求EWS托管API办公室365 我想使用带有的access_token网络应用产生。这是失败在service.AutodiscoverUrl('mailid', delegate(string url){return true})并获得错误'自动发现服务找不到。'。如何将Web应用程序与EWS托管API用于Office 365?

我正在使用以下代码使用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. 

我可以使用Web应用程序与EWS托管API的办公室365或它是有限的本机应用程序?

回答

0

EWS支持的Oauth Authentcation但却自动发现不那么

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

不会工作,如果你已正确设置许可,不得以任何天青EWS请求,应该工作正常。因为只有一个EWS端点Office365你不需要使用自动发现只要使用

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/

干杯 格伦

+0

'service.AutodiscoverUrl( 'mailid',委托(字符串URL){返回true})'这工作,如果我使用本机应用程序。 –

+0

然后启用跟踪并查看正在发送的头文件之间的区别,这些头文件将立即告诉您发生了什么以及发生了什么问题。 –

+0

谢谢,与网络应用程序;我只为'应用程序权限'生成access_token。现在可以使用access_token进行EWS请求。 –

相关问题