Source:
public AuthenticationResult getAuthTokenInBackground(final AuthenticationRequest request) throws AuthenticationException { AuthenticationResult authResult = null; verifyNotOnMainThread(); Account targetAccount = null; Account[] accountList = mAcctManager.getAccountsByType(AuthenticationConstants.Broker.BROKER_ACCOUNT_TYPE); if (!TextUtils.isEmpty(request.getBrokerAccountName())) { targetAccount = findAccount(request.getBrokerAccountName(), accountList); } else { try { UserInfo[] users = getBrokerUsers(); UserInfo matchingUser = findUserInfo(request.getUserId(), users); if (matchingUser != null) { targetAccount = findAccount(matchingUser.getDisplayableId(), accountList); } } catch (IOException | AuthenticatorException | OperationCanceledException e) { Logger.e(TAG, e.getMessage(), "", ADALError.BROKER_AUTHENTICATOR_IO_EXCEPTION, e); } } if (targetAccount != null) { Bundle brokerOptions = getBrokerOptions(request); AccountManagerFuture<Bundle> result; try { result = mAcctManager.getAuthToken(targetAccount, AuthenticationConstants.Broker.AUTHTOKEN_TYPE, brokerOptions, false, null , mHandler); Logger.v(TAG, "Received result from Authenticator"); Bundle bundleResult = result.getResult(); authResult = getResultFromBrokerResponse(bundleResult); } catch (OperationCanceledException e) { Logger.e(TAG, "Authenticator cancels the request", "", ADALError.AUTH_FAILED_CANCELLED, e); } catch (AuthenticatorException e) { Logger.e(TAG, "Authenticator cancels the request", "", ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING); } catch (IOException e) { Logger.e(TAG, "Authenticator cancels the request", "", ADALError.BROKER_AUTHENTICATOR_IO_EXCEPTION); } Logger.v(TAG, "Returning result from Authenticator"); return authResult; } else { Logger.v(TAG, "Target account is not found"); } return null; }

Target:
public AuthenticationResult getAuthTokenInBackground(final AuthenticationRequest request) throws AuthenticationException { AuthenticationResult authResult = null; verifyNotOnMainThread(); Account targetAccount = null; Account[] accountList = mAcctManager.getAccountsByType(AuthenticationConstants.Broker.BROKER_ACCOUNT_TYPE); if (!TextUtils.isEmpty(request.getBrokerAccountName())) { targetAccount = findAccount(request.getBrokerAccountName(), accountList); } else { try { UserInfo[] users = getBrokerUsers(); UserInfo matchingUser = findUserInfo(request.getUserId(), users); if (matchingUser != null) { targetAccount = findAccount(matchingUser.getDisplayableId(), accountList); } } catch (IOException | AuthenticatorException | OperationCanceledException e) { Logger.e(TAG, e.getMessage(), "", ADALError.BROKER_AUTHENTICATOR_IO_EXCEPTION, e); } } if (targetAccount != null) { Bundle brokerOptions = getBrokerOptions(request); try { final AccountManagerFuture<Bundle> result = mAcctManager.getAuthToken(targetAccount, AuthenticationConstants.Broker.AUTHTOKEN_TYPE, brokerOptions, false, null, mHandler); Logger.v(TAG, "Received result from Authenticator"); Bundle bundleResult = result.getResult(); authResult = getResultFromBrokerResponse(bundleResult); } catch (OperationCanceledException e) { Logger.e(TAG, "Authenticator cancels the request", "", ADALError.AUTH_FAILED_CANCELLED, e); } catch (AuthenticatorException e) { Logger.e(TAG, "Authenticator cancels the request", "", ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING); } catch (IOException e) { Logger.e(TAG, "Authenticator cancels the request", "", ADALError.BROKER_AUTHENTICATOR_IO_EXCEPTION); } Logger.v(TAG, "Returning result from Authenticator"); return authResult; } else { Logger.v(TAG, "Target account is not found"); } return null; }