code: @Beta
    public static GoogleCredential fromStream(InputStream credentialStream, HttpTransport transport,
        JsonFactory jsonFactory) throws IOException {
      Preconditions.checkNotNull(credentialStream);
      Preconditions.checkNotNull(transport);
      Preconditions.checkNotNull(jsonFactory);
  
      JsonObjectParser parser = new JsonObjectParser(jsonFactory);
      GenericJson fileContents = parser.parseAndClose(
          credentialStream, OAuth2Utils.UTF_8, GenericJson.class);
      String fileType = (String) fileContents.get("type");
      if (fileType == null) {
        throw new IOException("Error reading credentials from stream, 'type' field not specified.");
      }
      if (USER_FILE_TYPE.equals(fileType)) {
        return fromStreamUser(fileContents, transport, jsonFactory);
      }
      if (SERVICE_ACCOUNT_FILE_TYPE.equals(fileType)) {
        return fromStreamServiceAccount(fileContents, transport, jsonFactory);
      }
      throw new IOException(String.format(
          "Error reading credentials from stream, 'type' value '%s' not recognized."
              + " Expecting '%s' or '%s'.",
          fileType, USER_FILE_TYPE, SERVICE_ACCOUNT_FILE_TYPE));
    }
docs: {@link Beta} <br/>
  Return a credential defined by a Json file.
  
  @param credentialStream the stream with the credential definition.
  @param transport the transport for Http calls.
  @param jsonFactory the factory for Json parsing and formatting.
  @return the credential defined by the credentialStream.
  @throws IOException if the credential cannot be created from the stream.