google-cloud-lib/src/main/java/com/streamsets/pipeline/stage/lib/GoogleCloudCredentialsConfig.java
private Credentials getCredentials(Stage.Context context, List<Stage.ConfigIssue> issues) {
    Credentials credentials = null;

    File credentialsFile;
    if (Paths.get(path).isAbsolute()) {
      credentialsFile = new File(path);
    } else {
      credentialsFile = new File(context.getResourcesDirectory(), path);
    }

    if (!credentialsFile.exists() || !credentialsFile.isFile()) {
      LOG.error(GOOGLE_01.getMessage(), credentialsFile.getPath());
      issues.add(context.createConfigIssue(
          Groups.CREDENTIALS.name(), CONF_CREDENTIALS_CREDENTIALS_PROVIDER,
          GOOGLE_01,
          credentialsFile.getPath()
      ));
      return null;
    }

    try (InputStream in = new FileInputStream(credentialsFile)) {
      credentials = ServiceAccountCredentials.fromStream(in);
    } catch (IOException | IllegalArgumentException e) {
      LOG.error(GOOGLE_02.getMessage(), e);
      issues.add(context.createConfigIssue(
          Groups.CREDENTIALS.name(), CONF_CREDENTIALS_CREDENTIALS_PROVIDER,
          GOOGLE_02
      ));
    }

    return credentials;
  }
private Credentials getCredentials(Stage.Context context, List<Stage.ConfigIssue> issues) {
    Credentials credentials = null;

    File credentialsFile;
    if (Paths.get(path).isAbsolute()) {
      credentialsFile = new File(path);
    } else {
      credentialsFile = new File(context.getResourcesDirectory(), path);
    }

    if (!credentialsFile.exists() || !credentialsFile.isFile()) {
      LOG.error(GOOGLE_01.getMessage(), credentialsFile.getPath());
      issues.add(context.createConfigIssue(
          Groups.CREDENTIALS.name(), CONF_CREDENTIALS_CREDENTIALS_PROVIDER,
          GOOGLE_01,
          credentialsFile.getPath()
      ));
      return null;
    }

    try (InputStream in = new FileInputStream(credentialsFile)) {
      credentials = ServiceAccountCredentials.fromStream(in);
    } catch (IOException | IllegalArgumentException e) {
      LOG.error(GOOGLE_02.getMessage(), e);
      issues.add(context.createConfigIssue(
          Groups.CREDENTIALS.name(), CONF_CREDENTIALS_CREDENTIALS_PROVIDER,
          GOOGLE_02
      ));
    }

    return credentials;
  }
Reads a JSON credentials file for a service account from and returns any errors.

@param issues list to append any discovered issues.
@return a generic credentials object