diff --git a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java index 7162fda45..f3cf91a8a 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java @@ -236,16 +236,16 @@ protected ExternalAccountCredentials(ExternalAccountCredentials.Builder builder) this.clientId = builder.clientId; this.clientSecret = builder.clientSecret; - if (builder.tokenUrl == null) { + this.tokenUrl = builder.tokenUrl; + if (this.tokenUrl == null) { try { this.tokenUrl = DEFAULT_TOKEN_URL.replace("{UNIVERSE_DOMAIN}", this.getUniverseDomain()); } catch (IOException e) { // Throwing an IOException would be a breaking change, so wrap it here. + // This should not happen for this credential type. throw new IllegalStateException( "Error occurred when attempting to retrieve universe domain.", e); } - } else { - this.tokenUrl = builder.tokenUrl; } this.scopes =