code: protected void checkParamsForAuth(AUTH_REQUIREMENTS required) throws IOException {
      if (!clientSecretsFilename.isEmpty()) {
        File clientSecrets = new File(clientSecretsFilename);
        if (!clientSecrets.exists()) {
          throw new IOException(
              "Client secrets file " + clientSecretsFilename + " does not exist." +
              CLIENT_SECRETS_INSTRUCTIONS);   
        }
      } else {
       if (required == AUTH_REQUIREMENTS.CLIENT_SECRETS_ONLY) {
         throw new IOException(
             "Client secrets file has to be specified (API key can not be used)." 
                 + CLIENT_SECRETS_INSTRUCTIONS); 
       }
       if (apiKey.isEmpty() && required != AUTH_REQUIREMENTS.NONE) {
         throw new IOException(
             "Either an API key or a client secrets file have to be specified." 
                 + CLIENT_SECRETS_INSTRUCTIONS);
       }
      }
    }
docs: Checks that one of API key or client secrets is specified and valid.
  Depending on the use case no auth. might be allowed but some use cases
  require it and some only work with client_secrets (and not API key).