Source:
<code>private void setItemToCacheForUser(final String resource, final String clientId, final AuthenticationResult result, final String userId) { logReturnedToken(result); Logger.v(TAG, "Save regular token into cache."); final CacheEvent cacheEvent = new CacheEvent(EventStrings.TOKEN_CACHE_WRITE); cacheEvent.setRequestId(mTelemetryRequestId); Telemetry.getInstance().startEvent(mTelemetryRequestId, EventStrings.TOKEN_CACHE_WRITE); <START> String authority = mAuthority; <END> if (!StringExtensions.isNullOrBlank(result.getAuthority())) { authority = result.getAuthority(); } mTokenCacheStore.setItem(CacheKey.createCacheKeyForRTEntry(authority, resource, clientId, userId), TokenCacheItem.createRegularTokenCacheItem(authority, resource, clientId, result)); cacheEvent.setTokenTypeRT(true); if (result.getIsMultiResourceRefreshToken()) { Logger.v(TAG, "Save Multi Resource Refresh token to cache"); mTokenCacheStore.setItem(CacheKey.createCacheKeyForMRRT(authority, clientId, userId), TokenCacheItem.createMRRTTokenCacheItem(authority, clientId, result)); cacheEvent.setTokenTypeMRRT(true); } if (!StringExtensions.isNullOrBlank(result.getFamilyClientId()) && !StringExtensions.isNullOrBlank(userId)) { Logger.v(TAG, "Save Family Refresh token into cache"); final TokenCacheItem familyTokenCacheItem = TokenCacheItem.createFRRTTokenCacheItem(authority, result); mTokenCacheStore.setItem(CacheKey.createCacheKeyForFRT(authority, result.getFamilyClientId(), userId), familyTokenCacheItem); cacheEvent.setTokenTypeFRT(true); } Telemetry.getInstance().stopEvent(mTelemetryRequestId, cacheEvent, EventStrings.TOKEN_CACHE_WRITE); }</code><technical_language>update mAuthority</technical_language>

Target:
private void setItemToCacheForUser(final String resource, final String clientId, final AuthenticationResult result, final String userId) { logReturnedToken(result); Logger.v(TAG, "Save regular token into cache."); final CacheEvent cacheEvent = new CacheEvent(EventStrings.TOKEN_CACHE_WRITE); cacheEvent.setRequestId(mTelemetryRequestId); Telemetry.getInstance().startEvent(mTelemetryRequestId, EventStrings.TOKEN_CACHE_WRITE); if (!StringExtensions.isNullOrBlank(result.getAuthority())) { mAuthority = result.getAuthority(); } mTokenCacheStore.setItem(CacheKey.createCacheKeyForRTEntry(mAuthority, resource, clientId, userId), TokenCacheItem.createRegularTokenCacheItem(mAuthority, resource, clientId, result)); cacheEvent.setTokenTypeRT(true); if (result.getIsMultiResourceRefreshToken()) { Logger.v(TAG, "Save Multi Resource Refresh token to cache"); mTokenCacheStore.setItem(CacheKey.createCacheKeyForMRRT(mAuthority, clientId, userId), TokenCacheItem.createMRRTTokenCacheItem(mAuthority, clientId, result)); cacheEvent.setTokenTypeMRRT(true); } if (!StringExtensions.isNullOrBlank(result.getFamilyClientId()) && !StringExtensions.isNullOrBlank(userId)) { Logger.v(TAG, "Save Family Refresh token into cache"); final TokenCacheItem familyTokenCacheItem = TokenCacheItem.createFRRTTokenCacheItem(mAuthority, result); mTokenCacheStore.setItem(CacheKey.createCacheKeyForFRT(mAuthority, result.getFamilyClientId(), userId), familyTokenCacheItem); cacheEvent.setTokenTypeFRT(true); } Telemetry.getInstance().stopEvent(mTelemetryRequestId, cacheEvent, EventStrings.TOKEN_CACHE_WRITE); }