I am learning the identity server 4, about the SSO authentication.
I want to get httpContextAccessor with email which is logged in using Identity Server 4. I set scope - Email and Name.
But it will not working.
Here is my code of client webApi project.
builder.Services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
{
if (builder.Environment.IsDevelopment())
{
options.Authority = "https://localhost:44385";
}
options.Audience = "api1";
options.RequireHttpsMetadata = false;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false,
};
});
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("ApiScope", policy =>
{
policy.RequireAuthenticatedUser();
policy.RequireClaim("scope", "api1");
});
});