diff --git a/jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryAuthenticator.java b/jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryAuthenticator.java index 5070f6d3d0..1dc690afe9 100644 --- a/jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryAuthenticator.java +++ b/jib-core/src/main/java/com/google/cloud/tools/jib/registry/RegistryAuthenticator.java @@ -269,6 +269,8 @@ String getAuthRequestParameters(String scope) { String serviceScope = getServiceScopeRequestParameters(scope); return isOAuth2Auth() ? serviceScope + // https://github.com/GoogleContainerTools/jib/pull/1545 + + "&client_id=jib.da031fe481a93ac107a95a96462358f9" + "&grant_type=refresh_token&refresh_token=" // If OAuth2, credential.getPassword() is a refresh token. + Verify.verifyNotNull(credential).getPassword() diff --git a/jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryAuthenticatorTest.java b/jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryAuthenticatorTest.java index 43fe8e79f8..09f95d8e54 100644 --- a/jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryAuthenticatorTest.java +++ b/jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryAuthenticatorTest.java @@ -70,6 +70,7 @@ public void testAuthRequestParameters_oauth2() { registryAuthenticator.setCredential(Credential.basic("", "oauth2_access_token")); Assert.assertEquals( "service=someservice&scope=repository:someimage:scope" + + "&client_id=jib.da031fe481a93ac107a95a96462358f9" + "&grant_type=refresh_token&refresh_token=oauth2_access_token", registryAuthenticator.getAuthRequestParameters("scope")); }