I have implemented an Identity Provider and a client application using Code flow. When validating he token and going through the claims, I can;t find the claims associated with the user I am suing. Code is very similar to Identity Server 4 Authorization Code Flow example
private IEnumerable<Claim> ValidateToken(string token)
{
var certPath = Path.Combine(Server.MapPath("~/bin"), "SscSign.pfx");
var cert = new X509Certificate2(certPath);
var x509SecurityKey = new X509SecurityKey(cert);
var parameters = new TokenValidationParameters
{
RequireSignedTokens = true,
ValidAudience = audience,
ValidIssuer = validIssuer,
IssuerSigningKey = new X509SecurityKey(cert),
RequireExpirationTime = true,
ClockSkew = TimeSpan.FromMinutes(5)
};
var handler = new JwtSecurityTokenHandler();
SecurityToken jwt;
var id = handler.ValidateToken(token, parameters, out jwt);
foreach (Claim claim in id.Claims)
{
**I can't see any claim for key email**
}
this.Request.GetOwinContext().Authentication.SignOut("TempCookie");
return id.Claims;
}
I would appreciate it if anyone can help me read the email claim. @bayardw