コード例 #1
0
        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);
            }
        }
コード例 #2
0
 private Task WriteAuthenticationError(HttpContext context, JwtSimpleServerContext jwtSimpleServerContext)
 {
     return(WriteResponseError(context, jwtSimpleServerContext.GetError()));
 }