使用针对Office365的oauth2身份验证对用户进行身份验证时遇到问题。使用以下代码
var cac = new ActiveDirectory.ClientAssertionCertificate("AppID", new
X509Certificate2());
AuthenticationResult authenticationResult12 =
authenticationContext.AcquireTokenAsync(serverName, cac).Result;
ExchangeService exchangeService = new
ExchangeService(ExchangeVersion.Exchange2007_SP1);
exchangeService.Url = new Uri(serverName + "EWS/Exchange.asmx");
exchangeService.TraceEnabled = true;
exchangeService.TraceFlags = TraceFlags.All;
exchangeService.Credentials = new
OAuthCredentials(authenticationResult12.AccessToken);
exchangeService.FindFolders(WellKnownFolderName.Root, new FolderView(10));
我正在获取令牌,并且还能够使用EWS(ExchangeService)创建服务,但是在使用EWS服务获取根文件夹时,它给出了一个异常,因为“请求失败。远程服务器返回了错误:(401)未经授权。”
并使用以下内容
var userId = new
ActiveDirectory.UserIdentifier(UserID,UserIdentifierType.OptionalDisplayableId);
string clientSecret = "Client Secret key";
AuthenticationResult result1 =
authenticationContext.AcquireTokenAsync(serverName, clientID, clientAppUri,
new PlatformParameters(PromptBehavior.Always),userId, clientSecret).Result;
我收到“ AADSTS7000218:请求正文必须包含以下参数:“ client_assertion”或“ client_secret”。例外。
我想使用ExchangeService对Office的用户帐户帐户进行身份验证
通过oauth2身份验证。
谁能帮我这个忙。
谢谢