protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { Auth0Authenticator auth0Authenticator = container.Resolve <Auth0Authenticator>(); base.ApplicationStartup(container, pipelines); pipelines.EnableJwtBearerAuthentication( new JwtBearerAuthenticationConfiguration { //Challenge = "Guest", TokenValidationParameters = new TokenValidationParameters { // The signing key must match! ValidateIssuerSigningKey = true, IssuerSigningKey = jwtSigningKey, // Validate the JWT Issuer (iss) claim ValidateIssuer = true, ValidIssuer = $"https://{AuthSettings.Auth0Domain}/", // Validate the JWT Audience (aud) claim ValidateAudience = true, ValidAudience = AuthSettings.Auth0ApiIdentifier, // Validate the token expiry ValidateLifetime = true, ClockSkew = TimeSpan.Zero, ValidateActor = true, }, } ); pipelines.BeforeRequest.AddItemToEndOfPipeline(async(context, cancelToken) => { if (context.CurrentUser != null) { UserInfo userInfo = await auth0Authenticator.GetUserInfo(FetchBearerToken(context)); if (userInfo != null) { context.SetCurrentUserInfo(userInfo); context.CurrentUser.AddIdentity(new ClaimsIdentity(userInfo.ToClaims())); } } return(null); }); pipelines.AfterRequest.AddItemToEndOfPipeline(context => { Console.WriteLine(Print(context)); }); }