Hello guys,
I am getting this below error while validating the token
IDX10500: Signature validation failed. Unable to resolve SecurityKeyIdentifier: 'SecurityKeyIdentifier
(
IsReadOnly = False,
Count = 1,
Clause[0] = System.IdentityModel.Tokens.NamedKeySecurityKeyIdentifierClause
)
',
token: ‘{“kid”:“B3_K51euuDM9ug0Vq_BK-JLdwqbfDNVPyqcxPgwPDkY”,“alg”:“RS256”}.{“ver”:1,“jti”:“AT.Us5HJ2tXuDon4CpS2Jetvm7h8mnK25L6dMZ089_eaFE”,“iss”:“https://dev-396278.oktapreview.com/oauth2/default",“aud”:“api://default”,“iat”:1544508608,“exp”:1544512208,“cid”:“0oai240z9blScGGeF0h7”,“uid”:“00uhzsq8pw5e6bWGe0h7”,“scp”:[“openid”],“sub”:“0oai240z9blScGGeF0h7”,“name”:“Prashant”,“groups”:[“Everyone”,"Visitor”]}’.
I am not getting exact root cause of this.
below is the code for validating the token.
public async Task ValidateToken(
string token,
string issuer,
mspro::Microsoft.IdentityModel.Protocols.IConfigurationManager<Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration> configurationManager,
CancellationToken ct = default(CancellationToken))
{
if (string.IsNullOrEmpty(token)) throw new ArgumentNullException(nameof(token));
if (string.IsNullOrEmpty(issuer)) throw new ArgumentNullException(nameof(issuer));
var discoveryDocument = await configurationManager.GetConfigurationAsync(ct).ConfigureAwait(false);
var signingKeys = discoveryDocument.SigningKeys;
var validationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
{
ValidateAudience = false,
ValidateLifetime = false,
ValidIssuer = issuer,
};
try
{
var principal = new System.IdentityModel.Tokens.JwtSecurityTokenHandler()
.ValidateToken(token, validationParameters, out var rawValidatedToken);
return (JwtSecurityToken)rawValidatedToken;
}
catch (Microsoft.IdentityModel.Tokens.SecurityTokenValidationException ex)
{
// Logging, etc.
Log.Error("Error in token validation: ", ex.Message);
return null;
}
}
I am passing the same issue as got in the token’s “iss” attribute in the error response.
Any kind of help is much appreciated please.