![]() swagger.AddSecurityDefinition( "Bearer", new OpenApiSecurityScheme().// To Enable authorization using Swagger (JWT).//Demo Purpose, I have Passed HardCoded User Information.private async Task AuthenticateUser(LoginModel login).return new JwtSecurityTokenHandler().WriteToken(token).var token = new JwtSecurityToken(_config,.var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256).var securityKey = new SymmetricSecurityKey((_config)).private string GenerateJSONWebToken(LoginModel userInfo).public AuthenticateController(IConfiguration config)./// Constructor Injection to access all methods or simply DI(Dependency Injection).public class AuthenticateController : BaseController. ![]() ![]() namespace AuthenticationandAuthorization.Controllers.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |