Since $A$ is symmetric and real, we can find an orthogonal matrix $P$ such that $X=P^tDP$, where $D$ is diagonal. Since $P$ is orthogonal, $x\in S^{n-1}$ if and only if $Px\in S^{n-1}$, and $$g_A(x)=\langle Ax,x\rangle=\langle P^tDPx,x\rangle=\langle DPx,Px\rangle=g_D(Px).$$
So we have to deal with the case $D$ diagonal, namely $D=\operatorname{Diag}(\lambda_1,\ldots,\lambda_n)$, where $\lambda_1\leq \lambda_2\leq \ldots\leq \lambda_n$. We have, if $g_D$ reaches a maximum at $x$, that $$\max_j\lambda_j\leq g_D(x)=\sum_{j=1}^n\lambda_jx_j^2\leq \max_{j}\lambda_j$$
(the maximum is greater than $g_d(v_j)$, where $v_j$ is an eigenvector for $\lambda_j$)
so $g_D(x)=\lambda_n$. Denoting $(v)_k$ the $k$-th component of the vector $v$, we have $(Dx)_k=\lambda_kx_k\leq \lambda_nx_k$, so we have $x_k=0$ if $\lambda_k<\lambda_n$ and $x$ is an eigenvector for $D$. We do the same for the minimum considering $-D$.