private async Task AuthenticateToTooGoodToGoServices() { _logger.LogInformation("TooGoodToGoNotifier isn't authenticated, authenticating to TooGoodToGo's services"); AuthenticateByEmailResponse authenticateByEmailResponse = await _tooGoodToGoService.AuthenticateByEmailAsync(); int pollingAttempts = 0; AuthenticateByPollingIdResponse authenticateByPollingIdResponse; while (true) { pollingAttempts++; _logger.LogInformation("PollingId request attempt n°{pollingAttempts}", pollingAttempts); authenticateByPollingIdResponse = await _tooGoodToGoService.AuhenticateByPollingIdAsync(authenticateByEmailResponse.PollingId); if (authenticateByPollingIdResponse != null) { _context.AccessToken = authenticateByPollingIdResponse.AccessToken; _context.RefreshToken = authenticateByPollingIdResponse.RefreshToken; _context.UserId = authenticateByPollingIdResponse.StartupData.User.UserId; break; } await Task.Delay(TimeSpan.FromSeconds(15)); } _logger.LogInformation("Ended authenticating to TooGoodToGo's services"); }