Let's denote $Y = E(X|\mathfrak{G})$
$\color{blue}{\text{Step 1:}}$ let's suppose $X \in L^2$, then since $EX^2 = EY^2$, we have
\begin{align}
E\left(X - Y\right)^2 =& E(X^2) - 2E(XY) + E(Y^2) \\
=& EX^2 + EY^2 - 2E\left(E(XY|\mathfrak{G})\right) \\
=& EX^2 + EY^2 - 2E\left(YE(X|\mathfrak{G})\right) \\
=& EX^2 + EY^2 - 2EY^2 = 0
\end{align}
so $X=Y$ almost surely.
$\color{blue}{\text{Step 2:}}$ Now we remove the assumption $X \in L^2$. Then we need to consider $X' = X\wedge a \vee b$ and $Y' = Y\wedge a \vee b$, i.e. the truncated version of $X$ and $Y$. We will see $X' = Y'$ almost surely, then by sending $a \to +\infty$ and $b\to -\infty$, we see $X = Y$ almost surely.
To prove $X'= Y'$ almost surely, we will prove $E(X'|\mathfrak{G}) = Y'$, then since $X'$ and $Y'$ still have the same distribution, by $\color{blue}{\text{Step 1}}$ we see $X' = Y'$ almost surely.
So all we need to do now is to prove $$E(X'|\mathfrak{G}) = Y'$$
Firstly of all, $Y'$ is $\mathfrak{G}$-measurable.
Then by Jensen's inequality applied on conditional expectation, we have
$$E(X\wedge a|\mathfrak{G}) \leq E(X|\mathfrak{G})\wedge a = Y\wedge a$$
However, since $E(X\wedge a) = E(Y\wedge a)$, the above inequality can't be strict on a set of positive probability, so we get
$$E(X\wedge a|\mathfrak{G}) = Y\wedge a$$
By a similar argument, we get
$$E(X\wedge a \vee b|\mathfrak{G}) = Y\wedge a\vee b$$