public async Task Synchronize(CancellationToken cancellationToken)
        {
            var bearerToken = await _authenticator.GetBearerTokenForApplicationAsync();

            _bearerTokenSetter.SetBearerToken(bearerToken, false);

            _currentUserSetter.SetCurrentUserOid(_synchronizationUserOid);

            var currentUser    = _claimsProvider.GetCurrentUser();
            var claimsIdentity = new ClaimsIdentity();

            claimsIdentity.AddClaim(new Claim(ClaimsExtensions.Oid, _synchronizationUserOid.ToString()));
            currentUser.AddIdentity(claimsIdentity);

            foreach (var plant in await _plantCache.GetPlantWithAccessForUserAsync(_synchronizationUserOid))
            {
                _logger.LogInformation($"Synchronizing plant {plant}...");

                _plantSetter.SetPlant(plant);
                await _claimsTransformation.TransformAsync(currentUser);

                var startTime = TimeService.UtcNow;

                // todo Synchronize here

                var endTime = TimeService.UtcNow;

                _logger.LogInformation($"Plant {plant} synchronized. Duration: {(endTime - startTime).TotalSeconds}s.");
                _telemetryClient.TrackMetric("Synchronization Time", (endTime - startTime).TotalSeconds, "Plant", plant);
            }
        }
        private async Task <Project> FindOrCreatePreservationCopyOfProjectAsync(string plant, string projectName)
        {
            var projectToMoveTagInto = await _projectRepository.GetProjectWithTagsByNameAsync(projectName);

            if (projectToMoveTagInto == null)
            {
                var bearerToken = await _authenticator.GetBearerTokenForApplicationAsync();

                _bearerTokenSetter.SetBearerToken(bearerToken, false);

                _currentUserSetter.SetCurrentUserOid(_synchronizationUserOid);
                var pcsProject = await _projectApiService.TryGetProjectAsync(plant, projectName);

                if (pcsProject == null)
                {
                    throw new ArgumentException($"Unable to create local copy of {projectName}, not found.");
                }
                projectToMoveTagInto = new Project(plant, pcsProject.Name, pcsProject.Description);
                _projectRepository.Add(projectToMoveTagInto);
            }

            return(projectToMoveTagInto);
        }