code: public static ApacheHttpTransport createApacheHttpTransport(
        @Nullable URI proxyUri, @Nullable Credentials proxyCredentials)
        throws IOException, GeneralSecurityException {
      checkArgument(
          proxyUri != null || proxyCredentials == null,
          "if proxyUri is null than proxyCredentials should be null too");
  
      ApacheHttpTransport transport =
          new ApacheHttpTransport.Builder()
              .trustCertificates(GoogleUtils.getCertificateTrustStore())
              .setProxy(
                  proxyUri == null ? null : new HttpHost(proxyUri.getHost(), proxyUri.getPort()))
              .build();
  
      if (proxyCredentials != null) {
        ((DefaultHttpClient) transport.getHttpClient())
            .getCredentialsProvider()
            .setCredentials(new AuthScope(proxyUri.getHost(), proxyUri.getPort()), proxyCredentials);
      }
  
      return transport;
    }
docs: Create an {@link ApacheHttpTransport} for calling Google APIs with an optional HTTP proxy.
  
  @param proxyUri Optional HTTP proxy URI to use with the transport.
  @param proxyCredentials Optional HTTP proxy credentials to authenticate with the transport
  proxy.
  @return The resulting HttpTransport.
  @throws IOException If there is an issue connecting to Google's certification server.
  @throws GeneralSecurityException If there is a security issue with the keystore.