I have created a web API by following the sample added for Signicat https://github.com/signicat/Quick-start-guide-Authentication-.NET-Core
To get the nin information I have added the for like this:
options.Scope.Add("openid");
options.Scope.Add("profile");
options.Scope.Add("nin")
But in response, I am getting null for nin. I have tried to get information from the User like the following way.
var user = HttpContext.User;
name = user.FindFirstValue("name");
nin = user.FindFirstValue("nin");
Is there anything I am missing?
NB: This nin is configured for this client and getting the nin information when making manual requests via POSTMAN.
The OpenIDConnect handler blocks all unknown claims bydefault, so you need to explicitly map the claims that you care about, using code like
options.ClaimActions.MapUniqueJsonKey("nin", "nin");
options.ClaimActions.MapUniqueJsonKey("gender", "gender");
options.ClaimActions.MapUniqueJsonKey("birthdate", "birthdate");
You should check the raw token returned to the client and verify that the nin claim is really there first, just to be sure the client do get the desired claim.
To complement this answer, I wrote a blog post that goes into more detail about this topic: Debugging OpenID Connect claim problems in ASP.NET Core