My company's website is using google analytics to track various details, now we have a requirement to fetch all those raw data from google analytics servers and process using out internal tool.
I've created a small Java code using the HelloAnalytics Sample code (Analytics V4 and oAuth 2.0) to fetch session data from google servers. When i am running the same code from my personal computer it's running fine; but when i try to execute the same from company network, it fails throwing either "Connection Timeout" or "Unrecognized SSL message, plaintext connection?".
These issues are obviously due to firewall or the proxy server which is used by my company. I want to know if there's any way to connect to Google Analytics from a corporate network which uses a proxy server.
I've added the http.proxyHost and http.proxyPort as system property, nothing changed, got the same error. But when i added https.proxyHost and https.proxyPort instead of http port, it starting throwing error message "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
The Google documentations are not helping much :( . Any help is much appreciated.
My Code for reference:
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
//Trying both Explict token and also Client-Serect.json
GoogleCredential credential2 = new GoogleCredential().setFromTokenResponse(new TokenResponse().setAccessToken("Some token"));
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("client-secret.json")).createScoped(AnalyticsReportingScopes.all());
AnalyticsReporting service = new AnalyticsReporting.Builder(httpTransport, JSON_FACTORY, credential).build();
GetReportsRequest getReport = //Create the report object to fetch user sessions
GetReportsResponse response = service.reports().batchGet(getReport).execute();