Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

IdentityServer 4, Configuration Issue on OnTokenValidated Event

$
0
0

Hi Experts,

I got some problems in OpenIdConnectEvents in startup.cs that located in AspNetCore MVC Clinet project.

here is the code that i found in some example of identity server.

 OnTokenValidated = tokenValidatedContext =>
                    {
                        var identity = tokenValidatedContext.Ticket.Principal.Identity
                            as ClaimsIdentity;

                        var subjectClaim = identity.Claims.FirstOrDefault(z => z.Type == "sub");

                        var newClaimsIdentity = new ClaimsIdentity(
                          tokenValidatedContext.Ticket.AuthenticationScheme,
                          "given_name","role");

                        newClaimsIdentity.AddClaim(subjectClaim);

                        tokenValidatedContext.Ticket = new AuthenticationTicket(
                            new ClaimsPrincipal(newClaimsIdentity),
                            tokenValidatedContext.Ticket.Properties,
                            tokenValidatedContext.Ticket.AuthenticationScheme);

                        return Task.FromResult(0);
                    },

I cannot find the tokenValidatedContext.Ticket. Is there any replaceent ? I used the IdentityServer 2.02. Please help me. 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>