Source:
private void refreshToken(final CallbackHandler callbackHandle, final Activity activity, final AuthenticationRequest request, final RefreshItem refreshItem, final boolean useCache) { Logger.v(TAG, "Process refreshToken for " + request.getLogInfo() + " refreshTokenId:" + createHash(refreshItem.mRefreshToken)); if (!mConnectionService.isConnectionAvailable()) { Logger.w(TAG, "Connection is not available to refresh token", request.getLogInfo(), ADALError.DEVICE_CONNECTION_IS_NOT_AVAILABLE); callbackHandle.onError(new AuthenticationException( ADALError.DEVICE_CONNECTION_IS_NOT_AVAILABLE)); return; } try { Oauth2 oauthRequest = new Oauth2(request, mWebRequest); AuthenticationResult result = oauthRequest.refreshToken(refreshItem.mRefreshToken); if (useCache) { if (result == null || StringExtensions.IsNullOrBlank(result.getAccessToken())) { Logger.w(TAG, "Refresh token did not return accesstoken.", request.getLogInfo() + result.getErrorLogInfo(), ADALError.AUTH_FAILED_NO_TOKEN); removeItemFromCache(refreshItem); acquireTokenLocalCall(callbackHandle, activity, request); } else { Logger.v(TAG, "Refresh token is finished. Request:" + request.getLogInfo()); Logger.v(TAG, "Cache is used. It will set item to cache" + request.getLogInfo()); setRefreshItemToCache(refreshItem, request, result); callbackHandle.onSuccess(result); } } else { callbackHandle.onSuccess(result); } } catch (Exception exc) { Logger.e(TAG, "Error in refresh token for request:" + request.getLogInfo(), ExceptionExtensions.getExceptionMessage(exc), ADALError.AUTH_FAILED_NO_TOKEN, exc); if (useCache) { Logger.v(TAG, "Error in refresh token. Cache is used. It will remove item from cache" + request.getLogInfo()); removeItemFromCache(refreshItem); } callbackHandle.onError(exc); } }

Target:
private void refreshToken(final CallbackHandler callbackHandle, final Activity activity, final AuthenticationRequest request, final RefreshItem refreshItem, final boolean useCache) { Logger.v(TAG, "Process refreshToken for " + request.getLogInfo() + " refreshTokenId:" + createHash(refreshItem.mRefreshToken)); if (!mConnectionService.isConnectionAvailable()) { Logger.w(TAG, "Connection is not available to refresh token", request.getLogInfo(), ADALError.DEVICE_CONNECTION_IS_NOT_AVAILABLE); callbackHandle.onError(new AuthenticationException( ADALError.DEVICE_CONNECTION_IS_NOT_AVAILABLE)); return; } AuthenticationResult result = null; try { Oauth2 oauthRequest = new Oauth2(request, mWebRequest); result = oauthRequest.refreshToken(refreshItem.mRefreshToken); } catch (Exception exc) { Logger.e(TAG, "Error in refresh token for request:" + request.getLogInfo(), ExceptionExtensions.getExceptionMessage(exc), ADALError.AUTH_FAILED_NO_TOKEN, exc); if (useCache) { Logger.v(TAG, "Error in refresh token. Cache is used. It will remove item from cache" + request.getLogInfo()); removeItemFromCache(refreshItem); } callbackHandle.onError(exc); return; } if (useCache) { if (result == null || StringExtensions.IsNullOrBlank(result.getAccessToken())) { Logger.w(TAG, "Refresh token did not return accesstoken.", request.getLogInfo() + result.getErrorLogInfo(), ADALError.AUTH_FAILED_NO_TOKEN); removeItemFromCache(refreshItem); acquireTokenLocalCall(callbackHandle, activity, request); } else { Logger.v(TAG, "It finished refresh token request:" + request.getLogInfo()); Logger.v(TAG, "Cache is used. It will set item to cache" + request.getLogInfo()); setRefreshItemToCache(refreshItem, request, result); callbackHandle.onSuccess(result); } } else { Logger.v(TAG, "Cache is not used for Request:" + request.getLogInfo()); callbackHandle.onSuccess(result); } }