public static async Task <string> GenerateJwt(ClaimsIdentity identity, IJwtFactory jwtFactory, string userName, JwtIssuerOptions jwtOptions, JsonSerializerSettings serializerSettings) { var response = new { id = identity.Claims.Single(c => c.Type == "id").Value, auth_token = await jwtFactory.GenerateEncodedToken(userName, identity), expires_in = (int)jwtOptions.ValidFor.TotalSeconds }; string serializeResponse = JsonConvert.SerializeObject(response, serializerSettings); return(serializeResponse); }
public JwtFactory(IOptions <JwtIssuerOptions> jwtOptions) { _jwtOptions = jwtOptions.Value; ThrowIfInvalidOptions(_jwtOptions); }