如果您在使用EWS(Exchange Web Services)时遇到了不支持浏览器的委托身份验证的问题,可以尝试以下解决方法:
ExchangeService service = new ExchangeService();
service.Credentials = new NetworkCredential("serviceAccountUsername", "serviceAccountPassword", "domain");
service.Url = new Uri("https://example.com/EWS/Exchange.asmx");
// 使用服务帐户的身份验证
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "user@example.com");
// 使用EWS进行操作
// ...
ExchangeService service = new ExchangeService();
service.Url = new Uri("https://example.com/EWS/Exchange.asmx");
// 使用OAuth身份验证
string clientId = "yourClientId";
string clientSecret = "yourClientSecret";
string tenantId = "yourTenantId";
string authority = $"https://login.microsoftonline.com/{tenantId}";
ConfidentialClientApplication app = new ConfidentialClientApplication(clientId, authority, clientSecret, new TokenCache(), null);
string[] scopes = new string[] { "https://outlook.office.com/EWS.AccessAsUser.All" };
AuthenticationResult result = app.AcquireTokenForClient(scopes).Result;
service.Credentials = new OAuthCredentials(result.AccessToken);
// 使用EWS进行操作
// ...
请注意,上述代码示例中的URL和身份验证凭据需要根据您的实际情况进行修改。此外,根据您使用的EWS版本和编程语言,可能需要适当调整代码。
希望这些解决方法能够帮助您解决问题!
下一篇:不支持浏览器通知