code: private static Credentials getCredentials(ConnectionParameters parameters) throws IOException {
      if (parameters.isEmulator()) {
        return NoCredentials.getInstance();
      }
      InputStream jsonCredentialsStream = parameters.getJsonCredentialsStream();
      if (jsonCredentialsStream != null) {
        return ServiceAccountCredentials.fromStream(jsonCredentialsStream);
      }
      File jsonCredentialsFile = parameters.getJsonCredentialsFile();
      if (jsonCredentialsFile != null) {
        return ServiceAccountCredentials.fromStream(new FileInputStream(jsonCredentialsFile));
      }
      return ServiceAccountCredentials.getApplicationDefault();
    }
docs: Creates and returns the credentials from the given connection parameters.
  
  @param parameters
  the connection parameters
  @return the credentials for authenticating with the Datastore service.
  @throws IOException
  if any error occurs such as not able to read the credentials file.