Let $p$ odd prime. If $\omega\in\overline{\mathbb{F_p}}$ is a 8-th primitive root of unity.
Then if $\gamma=\omega+\omega^{-1}$.
Why is
i) $\gamma^p=\omega^ p+\omega^{-p}=\omega+\omega^{-1}=\gamma$ if $p\equiv\pm1 \ (mod \ 8)$
ii) $\gamma^p=\omega^ p+\omega^{-p}=\omega^3+\omega^{-3}=-(\omega+\omega^{-1})=\gamma$ if $p\equiv\pm3 \ (mod \ 8)$?
Thus
$\gamma^p=(-1)^{(p^2-1)/8}\gamma$ therefore $\gamma^p=\gamma$ if and only if $(-1)^{(p^2-1/8)}=1$ if and only if $\left( \displaystyle\frac{2}{p} \right)=(-1)^{(p^2-1)/8}$.
Thanks you all.
i) If $p \equiv \pm 1 \pmod 8$, then $\omega^p + \omega^{-p}$ is either $\omega^1 + \omega^{-1}$ or $\omega^{-1} + \omega^1$, which are both equal.
ii) If $p \equiv \pm 3 \pmod 8$, then $\omega^p + \omega^{-p}$ is either $\omega^3 + \omega^{-3}$ or $\omega^{-3} + \omega^3$, which are both equal. Factoring out an $\omega^4 = \omega^{-4} = -1$ gives us $-(\omega + \omega^{-1}) = -\gamma$.
The $(-1)^{(p^2-1)/8}$ is just a way of picking out the right sign. Honestly, if you know that $2$ is a QR mod $p$ iff $p \equiv \pm 1 \pmod 8$, you can just use that result directly, without passing through the $(-1)^{(p^2-1)/8}$ step.