IDX10511: Signature validation failed. Keys tried: '[PII of type 'System.Text.StringBuilder' is hidden.

Subin Vijayan 61 Reputation points
2022-08-08T14:58:08.777+00:00

Hello,

I am creating token thru auth mechanism for imap connectivity to read emails, Token is created successfully from below code but when I am validate jwt token, it throwing error

  1. Step

=============
Start Code creating token======================================================

var scopes = new[] { "https://outlook.office365.com/IMAP.AccessAsUser.All" };
var app = PublicClientApplicationBuilder.Create(xxxx-xxxxxx-xxxxx-xxxxx).WithAuthority(AadAuthorityAudience.AzureAdMultipleOrgs).Build();
var authentication = await app.AcquireTokenByUsernamePassword(scopes, xxx-yyy-yyyy, **************).ExecuteAsync();

var access_token=authentication?.AccessToken

=============
End Code creating token======================================================

  1. Step

===============
Below code using for validate token======================================================

var configManager = new ConfigurationManager<OpenIdConnectConfiguration>($"https://login.microsoftonline.com/<tenantid>/.well-known/openid-configuration", new OpenIdConnectConfigurationRetriever());

            var config =  configManager.GetConfigurationAsync().Result;  
              
            return new TokenValidationParameters()  
            {  
                ValidateLifetime = true,  
                ValidateAudience = true,  
                ValidateIssuer = true,     
                ValidIssuer = "https://sts.windows.net/<tenantid>/",  
                ValidAudience = "<clientid>",  
                IssuerSigningKeys=config.SigningKeys  
                 
            };  

===============
End code using for validate token======================================================

===============
START ERROR MESSAGE=======================================================
IDX10511: Signature validation failed. Keys tried: '[PII of type 'System.Text.StringBuilder' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
Number of keys in TokenValidationParameters: '0'.
Number of keys in Configuration: '0'.
Matched key was in 'Configuration'.
kid: '2ZQpJ3UpbjAYXYGaXEJl8lV0TOI'.
Exceptions caught:
'[PII of type 'System.Text.StringBuilder' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
token: '[PII of type 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.

===============
END ERROR MESSAGE=======================================================

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
Microsoft Security | Microsoft Identity Manager
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.