I've created an empty .net5 Web API project. the project should use Identity Server to generate JWT token for the users of the API.
startup.cs
public void ConfigureServices(IServiceCollection services){
services.AddDbContext<ApplicationDbContext>(...);
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddIdentityServer(...)
.AddAspNetIdentity<ApplicationUser>()
.AddConfigurationStore(...);
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer();
...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env){
...
app.UseAuthentication();
app.UseIdentityServer();
app.UseAuthorization();
...
}
The code compile with no error
Login function
var result = await _signInManager
.PasswordSignInAsync(model.Email, model.Password, false, lockoutOnFailure: false);
if (result.Succeeded)
{
_logger.LogInformation("User logged in.");
return Ok();
}
return BadRequest("Invalid Login Attempt");
I received the ok result from the server but no JWT returned at the headers of the response. Also I noticed that when I create a second request I found my previous login data stored on User property in the Controller.
my question is where to find the token generated by my endpoint?