Set<Long> accountIdsSet = Sets.newHashSet();
try {
LOGGER.info("Account IDs being recovered from the API. This may take a while...");
accountIdsSet = new ManagedCustomerDelegate(
authenticator.authenticate(userId, mccAccountId, false).build()).getAccountIds();
} catch (ApiException e) {
if (e.getMessage().contains("AuthenticationError")) {
// retries Auth once for expired Tokens
LOGGER.info("AuthenticationError, Getting a new Token...");
LOGGER.info("Account IDs being recovered from the API. This may take a while...");
accountIdsSet = new ManagedCustomerDelegate(
authenticator.authenticate(userId, mccAccountId, true).build()).getAccountIds();
} else {
LOGGER.error("API error: " + e.getMessage());
e.printStackTrace();