public async Task CreateAsync(AuthenticationTokenCreateContext context)
        {
            var clientid = context.Ticket.Properties.Dictionary["as:client_id"];
            var refreshTokenLifetime = context.OwinContext.Get<string>("as:RefreshTokenLifetime");

            var refreshTokenId = Guid.NewGuid().ToString("n");

            if (string.IsNullOrEmpty(clientid))
            {
                return;
            }

            context.Ticket.Properties.IssuedUtc = DateTime.UtcNow;
            context.Ticket.Properties.ExpiresUtc = DateTime.UtcNow.AddMinutes(Convert.ToDouble(refreshTokenLifetime));
            var token = context.SerializeTicket();

            var refreshDto = new RefreshTokenDto()
            {
                Id = refreshTokenId,
                ClientId = clientid,
                Subject = context.Ticket.Identity.Name,
                Token = token
            };

            await _redisRepo.InsertRefreshTokenAsync(refreshDto);

            context.SetToken(refreshTokenId);
        }
        public async Task InsertRefreshTokenAsync(RefreshTokenDto tokenDto)
        {
            IDatabase db = _redis.GetDatabase();
            string refreshKey = "refresh:" + tokenDto.Subject;

            var refreshValue = await db.StringGetAsync(refreshKey);
            if (!string.IsNullOrEmpty(refreshValue))
            {
                await db.KeyDeleteAsync(refreshValue.ToString());
            }
            string userValue = await JsonConvert.SerializeObjectAsync(tokenDto);

            await db.StringSetAsync(tokenDto.Id, userValue);
            await db.StringSetAsync(refreshKey, tokenDto.Id);
        }