用c#;
我可以使用通过本机应用生成的access_token来请求Office 365的EWS托管api。
我正在尝试使用网络应用生成的access_token。这在service.AutodiscoverUrl('mailid', delegate(string url){return true})
失败并且收到错误'无法找到自动发现服务。'。
我使用以下代码使用网络应用生成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 App与EWS托管API一起用于Office 365,还是仅限于本机应用程序?
答案 0 :(得分:0)
EWS支持Oauth认证,但自动发现不支持
service.AutodiscoverUrl('mailid', delegate(string url){return true})
如果您在Azure中正确设置了权限,则无法正常工作,任何EWS请求都可以正常工作。由于Office365中只有一个EWS端点,因此您无需使用自动发现
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
干杯 格伦