0

I'm using IdentityServer4 and im trying to figure out how to get current userId (guid) in protected API.. Upfront is BFF which proxy all requests to API. When I look in http context there is no user info available.. and User.isAuthenticated is always false.

What soud i make to get some user data in that API? Minimal current user UserId to query database..

.AddAuthentication("token")  
 .AddJwtBearer("token", options =>
        {
            options.Authority = "https://localhost:6666";
            options.MapInboundClaims = false;

            options.TokenValidationParameters = new TokenValidationParameters()
            {
                ValidateAudience = true,
                ValidTypes = new[] { "at+jwt" },
                
                NameClaimType = "name",
                RoleClaimType = "role"
            };
        });

The _contextAccessor.HttpContext.User.Identity.IsAuthenticated is always false

dami
  • 146
  • 1
  • 7

0 Answers0