Example #1
0
        public async Task <IActionResult> CreateToken([FromBody] IdentityServerTokenRequest request)
        {
            if (!this.ModelState.IsValid)
            {
                return(new UnprocessableEntityResult <IdentityServerTokenRequest>());
            }

            var token = await this.identityServerTools.IssueJwtAsync(
                lifetime : request.Lifetime,
                claims : request.Claims);

            return(this.Ok(new IdentityServerTokenResponse
            {
                Token = token,
            }));
        }
        private static async Task CreateToken(
            HttpContext context,
            IdentityServerTokenRequest request,
            IdentityServerTools identityServerTools)
        {
            var token = await identityServerTools.IssueJwtAsync(
                lifetime : request.Lifetime,
                claims : request.Claims);

            var response = new IdentityServerTokenResponse
            {
                Token = token,
            };

            await context.Response.WriteJsonAsync(response);
        }