@Override public Credentials create(PipelineOptions options) { GcpOptions gcpOptions = options.as(GcpOptions.class); try { CredentialFactory factory = InstanceBuilder.ofType(CredentialFactory.class) .fromClass(gcpOptions.getCredentialFactoryClass()) .fromFactoryMethod("fromOptions") .withArg(PipelineOptions.class, options) .build(); return factory.getCredential(); } catch (IOException | GeneralSecurityException e) { throw new RuntimeException("Unable to obtain credential", e); } } }