private async Task GenerateJwtToken(
            PasswordGrantType passwordGrandType,
            HttpContext context,
            IAuthenticationProvider authenticationProvider)
        {
            var simpleServerContext = JwtSimpleServerContext.Create(passwordGrandType.UserName, passwordGrandType.Password);
            await authenticationProvider.ValidateClientAuthentication(simpleServerContext);

            if (simpleServerContext.IsValid())
            {
                var jwtToken = await _jwtTokenEncoder.WriteToken(simpleServerContext.Claims);

                await WriteResponseAsync(StatusCodes.Status200OK, context, JsonConvert.SerializeObject(jwtToken));
            }
            else
            {
                await WriteAuthenticationError(context, simpleServerContext);
            }
        }
 private Task WriteAuthenticationError(HttpContext context, JwtSimpleServerContext jwtSimpleServerContext)
 {
     return(WriteResponseError(context, jwtSimpleServerContext.GetError()));
 }