public async Task <ActionResult <List <string> > > GenerateAccessTokensAsync(string clientId, string audience, int count = 100)
        {
            clientId = clientId ?? Config.Clients.FirstOrDefault().ClientId;
            var tokens = new List <string>();
            var users  = _userManager.Users.Take(count);

            foreach (var user in users)
            {
                var claims = new List <Claim>()
                {
                    new Claim("sub", user.Id),
                    new Claim(JwtClaimTypes.IssuedAt, _clock.UtcNow.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64)
                };

                var oToken = new IdentityServer4.Models.Token(OidcConstants.TokenTypes.AccessToken)
                {
                    CreationTime             = _clock.UtcNow.UtcDateTime,
                    Audiences                = { audience ?? "bcc.members" },
                    Issuer                   = $"{Request.Scheme}://{Request.Host}",
                    Lifetime                 = 10000,
                    Claims                   = claims.Distinct(new ClaimComparer()).ToList(),
                    ClientId                 = clientId,
                    AccessTokenType          = AccessTokenType.Jwt,
                    AllowedSigningAlgorithms = IdentityServerConstants.SupportedSigningAlgorithms.ToArray(),
                };

                var sToken = await _tokenService.CreateTokenAsync(oToken);

                tokens.Add(sToken);
            }


            return(Ok(tokens));
        }
        private IEnumerable <Claim> ReferenceTokenToClaims(IdentityServer4.Models.Token token)
        {
            var claims = new List <Claim>
            {
                new Claim(JwtClaimTypes.Issuer, token.Issuer),
                new Claim(JwtClaimTypes.NotBefore, new DateTimeOffset(token.CreationTime).ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64),
                new Claim(JwtClaimTypes.Expiration, new DateTimeOffset(token.CreationTime).AddSeconds(token.Lifetime).ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64)
            };

            foreach (var aud in token.Audiences)
            {
                claims.Add(new Claim(JwtClaimTypes.Audience, aud));
            }

            claims.AddRange(token.Claims);
            return(claims);
        }