0
當我嘗試使用下面的代碼創建身份驗證標頭時。我收到一條錯誤消息:「AADSTS70002:驗證憑證時出錯。AADSTS50012:提供了無效的客戶機密鑰。」現在,我確信,我在代碼中使用的祕密與我在AAD應用程序註冊中使用的祕密不匹配。任何人都可以通過我的應用程序註冊或如何在我的O365帳戶目錄中添加新的應用程序標識符來幫助我獲得客戶機密。AADSTS70002:驗證憑據時出錯。 AADSTS50012:提供無效的客戶端密鑰
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;
}
}