public List<Customer> getAccountsInfo(String userId, String mccAccountId, Set<Long> accountIds) throws OAuthException, ValidationException, IOException {
List<Customer> accounts = Lists.newArrayList();
AdWordsSession adWordsSession = authenticator.authenticate(userId, mccAccountId, false).build();
CustomerDelegate customerDelegate = new CustomerDelegate(adWordsSession);
for (Long accountId : accountIds) {
adWordsSession.setClientCustomerId(String.valueOf(accountId));
try {
accounts.add(customerDelegate.getCustomer());
} catch (ApiException e) {
if (e.getMessage().contains("AuthenticationError")) {
// retries Auth once for expired Tokens
LOGGER.info("AuthenticationError, Getting a new Token...");
adWordsSession = authenticator.authenticate(userId, mccAccountId, false).build();
customerDelegate = new CustomerDelegate(adWordsSession);
try {
accounts.add(customerDelegate.getCustomer());
} catch (ApiException e2) {
LOGGER.error("Skipping Account " + accountId + " error while getting it's information: " + e2.getMessage()); }
} else {
LOGGER.error("Skipping Account " + accountId + " error while getting it's information: " + e.getMessage());
}