public Task StoreAsync(PersistedGrant token)
        {
            var existing = _context.PersistedGrants.AsQueryable().SingleOrDefault(x => x.Key == token.Key);

            try
            {
                if (existing == null)
                {
                    _logger.LogDebug("{persistedGrantKey} not found in database", token.Key);

                    var persistedGrant = token.ToDocument();
                    _context.PersistedGrants.InsertOne(persistedGrant);
                }
                else
                {
                    _logger.LogDebug("{persistedGrantKey} found in database", token.Key);

                    token.UpdateEntity(existing);
                }
            }
            catch (Exception ex)
            {
                _logger.LogWarning("exception updating {persistedGrantKey} persisted grant in database: {error}", token.Key, ex.Message);
            }

            return(Task.FromResult(0));
        }
        public void PersistedGrantAutomapperConfigurationIsValid()
        {
            var model        = new PersistedGrant();
            var mappedEntity = model.ToDocument();
            var mappedModel  = mappedEntity.ToModel();

            Assert.NotNull(mappedModel);
            Assert.NotNull(mappedEntity);
            PersistedGrantMappers.Mapper.ConfigurationProvider.AssertConfigurationIsValid();
        }