The theorem is from Niven's number theory "Binary quadratic forms" 3.4 Theorem 3.10 page 163-164
Theorem $3.10 $: Let $f(x, y) = ax^2 + bxy + cy^2$ be a binary quadratic form with integral coefficients and discriminant $d$. If $d \neq 0$ and $d$ is not a perfect square , then $a \neq 0, c \neq 0$, and the only solution of the equation $f(x, y) = 0$ in integers is given by $x = y = 0$.
Proof : We may presume that $a \neq 0$ and $c \neq 0$, for if $a = 0 $or $c = 0$ then $ac = 0$ and $d = b^2 - 4ac = b^2$, a perfect square. Suppose that $x_0$ and $y_0$ are integers such that $f(x_0, y_0) = 0$. If $y_o = 0$ then $ax_0^2 = 0$, and hence $x_0 = 0$ because $a \neq 0$. If $x_0 = 0$, a parallel argument gives $y_0 = 0$. Consequently we take $x_0 \neq 0$ and $y_0 \neq 0$. By completing the square we see that $$4af( x, y) = (2ax + by)^2-dy^2$$ and hence $(2ax_0 + by_0)^2 = dy_0^2$ since $f(x_0, y_0) = 0$. But $dy^2 \neq 0$, and it follows by unique factorization that $d$ is a perfect square. The proof is now complete
I am quite confused, why unique factorization would lead d be a perfect square?
It seems for me to prove d is indeed the perfect square we have to prove that $\frac{x_0}{y_0}$ is an integer, since
$$d=(\frac{(2ax_0+by_0)}{y_0})^2$$
and such fact doesn't have much to do with Unique factorization. Thank you for your advices!