2016-04-28 58 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請求。 –

相關問題