예제 #1
0
        public async Task <IActionResult> CreateClientToken([FromBody] IdentityServerClientTokenRequest request)
        {
            if (!this.ModelState.IsValid)
            {
                return(new UnprocessableEntityResult <IdentityServerClientTokenRequest>());
            }

            var token = await this.identityServerTools.IssueClientJwtAsync(
                lifetime : request.Lifetime,
                clientId : request.ClientId,
                scopes : request.Scopes,
                audiences : request.Audiences);

            return(this.Ok(new IdentityServerTokenResponse
            {
                Token = token,
            }));
        }
        private static async Task CreateClientToken(
            HttpContext context,
            IdentityServerClientTokenRequest request,
            IdentityServerTools identityServerTools)
        {
            var token = await identityServerTools.IssueClientJwtAsync(
                lifetime : request.Lifetime,
                clientId : request.ClientId,
                scopes : request.Scopes,
                audiences : request.Audiences);

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

            await context.Response.WriteJsonAsync(response);
        }