GoogleIdTokenAuth { public static GoogleIdTokenAuth of(Optional<GoogleCredentials> credentials) { return of(Utils.getDefaultTransport(), credentials); } private  GoogleIdTokenAuth(HttpTransport httpTransport, Optional<GoogleCredentials> credentials); static GoogleIdTokenAuth of(Optional<GoogleCredentials> credentials); static GoogleIdTokenAuth of(GoogleCredentials credentials);  }
@Test public void testImpersonatedCredentials() throws IOException, GeneralSecurityException { Assume.assumeNotNull(credentials); final ImpersonatedCredentials impersonatedCredentials = ImpersonatedCredentials.newBuilder() .setScopes(ImmutableList.of("https: .setSourceCredentials(credentials) .setTargetPrincipal("styx-test-user@styx-oss-test.iam.gserviceaccount.com") .setLifetime(300) .setDelegates(ImmutableList.of()) .build(); assertThat(canAcquireIdToken(impersonatedCredentials), is(true)); }
@Test public void testServiceAccountCredentialsWithAccessToken() throws IOException, GeneralSecurityException { Assume.assumeNotNull(credentials); final GoogleCredentials serviceAccountCredentials; final URI keyUri = URI.create("gs: try (InputStream is = Files.newInputStream(Paths.get(keyUri))) { serviceAccountCredentials = GoogleCredentials.fromStream(is) .createScoped(ImmutableList.of( "https: "https: } serviceAccountCredentials.refresh(); final GoogleCredentials accessTokenCredentials = GoogleCredentials.newBuilder() .setAccessToken(serviceAccountCredentials.getAccessToken()) .build(); assertThat(canAcquireIdToken(accessTokenCredentials), is(true)); }