0

I am using GoogleApps Directory api to access the Googleapps. I have one query regarding Proxy , how to set the proxy credentials using directory API's.

As per googleApps API's documentation i can use class "GoogleNetHttpTransport" to set the Proxy (port and host).

static HttpTransport newProxyTransport() throws GeneralSecurityException, IOException { NetHttpTransport.Builder builder = new NetHttpTransport.Builder(); builder.trustCertificates(GoogleUtils.getCertificateTrustStore()); builder.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 3128))); return builder.build(); }

But if i have credentials for proxy server then how can i set, there is no mention about setting up proxy credentials.

Is there any GoogleApps api which allow to set proxy credentials along with hostname and port?

If no , then should i go for setDefault(Authenticator) which will set the proxy credentials to system property ?

Can anyone have idea about this. Any input on this is highly appreciable!

1 Answers1

0

You may refer with this documentation. For HTTP proxy with the Java client library, if your corporate proxy server were running on my.proxy.domain.com, on port 3128, you could add the following to your code before creating a service object for Google Calendar, Google Spreadsheets, etc.

System.setProperty("http.proxyHost", "my.proxy.domain.com");
System.setProperty("http.proxyPort", "3128");

Alternatively, this can be done on the command line when starting your servlet environment:

java -Dhttp.proxyHost=my.proxy.domain.com -Dhttp.proxyPort=3128

You may also refer with this related thread: Google Directory API using Service Account via Proxy

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59