0

While I'm trying to access the .p12 file, I am getting

java.net.SocketException: Connection reset while trying to fetch the data from google analytics using google analytics api

Here is the code:

private static Analytics initializeAnalytics() throws Exception {
    // Initializes an authorized analytics service object.

    // Construct a GoogleCredential object with the service account email
    // and p12 file downloaded from the developer console.
    HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    GoogleCredential credential = new GoogleCredential.Builder()
        .setTransport(httpTransport)
        .setJsonFactory(JSON_FACTORY)
        .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
        .setServiceAccountPrivateKeyFromP12File(new File(KEY_FILE_LOCATION))
        .setServiceAccountScopes(AnalyticsScopes.all())
        .build();

    // Construct the Analytics service object.
    return new Analytics.Builder(httpTransport, JSON_FACTORY, credential)
        .setApplicationName(APPLICATION_NAME).build();
  }
Laurel
  • 5,965
  • 14
  • 31
  • 57
praneeth
  • 11
  • 4
  • Possible duplicate of [java.net.SocketException: Connection reset](http://stackoverflow.com/questions/62929/java-net-socketexception-connection-reset) – Linda Lawton - DaImTo Aug 26 '16 at 08:57
  • @DalmTo Is there any other way of possibilities about this issue?While trying to load the initializeAnalytics() method the error it is happening.. – praneeth Aug 26 '16 at 11:27

0 Answers0