I have multiple claims being sent back in the profile scope. These claims include:
employeeType mail givenName
These accessToken claims are being automatically mapped to the same name. I would like them to be changed to change the mapping as follows:
employeeType = EmployeeType
mail = Mail
givenName = FirstName
I tried using MapJsonKey() but its' not working I also tried MapUniqueJsonKey(). I think these may only be used for userInfoClaims?
options.ClaimActions.MapJsonKey("EmployeeType", "employeeType");
options.ClaimActions.MapJsonKey("FirstName", "givenName");
options.ClaimActions.MapJsonKey("Email", "Mail");
Is there a way to map these to different name, or do I have to delete the claims and add them to the Prinical using OnTokenValidated hook?
This is my authentication configuration in startup.
services.AddAuthentication(options => {
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o =>
{
o.Cookie.Name = "GCOWebCookie";
o.AccessDeniedPath = "/AccessDenied";
})
.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options => {
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.Authority = config["OneId:Authority"];
options.ClientId = config["OneId:ClientId"];
options.ResponseType = "code";
options.ClientSecret = config["OneId:ClientSecret"];
options.SaveTokens = true;
//options.GetClaimsFromUserInfoEndpoint = true;
options.UsePkce = true;
//options.Scope.Add("profile"); These scopees are added by default
//options.Scope.Add("openid");