【发布时间】:2018-12-13 07:33:55
【问题描述】:
当我尝试使用以下代码创建身份验证标头时。我收到一条错误消息:“AADSTS70002:验证凭据时出错。AADSTS50012:提供了无效的客户端密码。”现在,我确信我在代码中使用的秘密与我在 AAD 应用程序注册中使用的秘密不匹配。任何人都可以帮助我了解如何从我的应用程序注册中获取客户端密码或如何在我的 O365 帐户目录中添加新的应用程序标识符。
private string GetAuthenticationHeader(AuthenticationInformation authenticationInformation){
try{
return RetryHelper.InvokeWithRetries(() =>
{
var clientCredential = new ClientCredential(authenticationInformation.ClientId, authenticationInformation.AppSecret);
var ac = new AuthenticationContext(authenticationInformation.Authority);
AuthenticationResult ar = ac.AcquireToken(authenticationInformation.Resource, clientCredential);
return ar.CreateAuthorizationHeader();
});
}
catch (Exception ex){
return ex.Message;
}
}
【问题讨论】: