-1

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

johnny 5
  • 19,893
  • 50
  • 121
  • 195
Sandra
  • 63
  • 3
  • 14
  • Maybe show us what you have sofar and we can actually help. The text "It doesn't work" doesn't help us figuring out your problem. –  May 16 '18 at 13:44
  • Edited the question with more detail. As you can see in the example user has email claim but I can't see it in the list of claims. – Sandra May 16 '18 at 14:56

1 Answers1

1

I'm sure you don't have a claim with email. You can check it here jwt.io

You have to define it in settings for Resources docs.identityserver.io

Che
  • 169
  • 8