private JwtSecurityToken CreateJwtSecurityToken(JwtTokenOptions tokenOptions, User user, SigningCredentials signingCredentials, string[] roles) { var jwt = new JwtSecurityToken( issuer: tokenOptions.Issuer, audience: tokenOptions.Audience, expires: _tokenExpiration, notBefore: DateTime.Now, claims: SetClaims(user, roles), signingCredentials: signingCredentials ); return(jwt); }
public JwtTokenHelper(IConfiguration configuration) { Configuration = configuration; _tokenOptions = Configuration.GetSection("TokenOptions").Get <JwtTokenOptions>(); _tokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.TokenExpiration); }