[step:Show that the Fourier coefficients are $\overline{\chi}(n)\tau(\chi)$]We claim that for every $n \in \{1,\dots,q\}$,
\begin{align*}
\widehat{\chi}(n)=\overline{\chi}(n)\tau(\chi).
\end{align*}
First suppose $\gcd(n,q)=1$. Let $b \in \mathbb{Z}$ be an inverse of $n$ modulo $q$, so $bn \equiv 1 \pmod q$. Multiplication by $n$ permutes the residue classes modulo $q$, so the substitution $s \equiv nr \pmod q$ gives
\begin{align*}
\widehat{\chi}(n)
&= \sum_{s=1}^{q} \chi(bs)e_q(s) \\
&= \chi(b)\sum_{s=1}^{q}\chi(s)e_q(s).
\end{align*}
Since $\chi(n)$ is a complex root of unity and $\chi(b)=\chi(n)^{-1}$, we have $\chi(b)=\overline{\chi}(n)$. Therefore
\begin{align*}
\widehat{\chi}(n)=\overline{\chi}(n)\tau(\chi).
\end{align*}
Now suppose $\gcd(n,q)=d>1$. Set $m:=q/d$, so $m$ is a proper divisor of $q$.
[claim:Primitivity gives a nontrivial unit congruent to $1$ modulo $m$]
There exists an integer $a$ such that $\gcd(a,q)=1$, $a\equiv 1\pmod m$, and $\chi(a)\ne 1$.
[/claim]
[proof]
Suppose instead that $\chi(a)=1$ for every integer $a$ satisfying $\gcd(a,q)=1$ and $a\equiv 1\pmod m$. We show that $\chi$ is induced from a character modulo $m$, contradicting the primitivity of $\chi$ modulo $q$.
For every unit residue class $u\in (\mathbb{Z}/m\mathbb{Z})^\times$, choose an integer $A_u$ such that $A_u\equiv u\pmod m$ and $\gcd(A_u,q)=1$. Such a lift exists by choosing, for each prime $p\mid q$, a residue not divisible by $p$ and compatible with $u\pmod m$. Define
\begin{align*}
\psi: (\mathbb{Z}/m\mathbb{Z})^\times &\to \mathbb{C}^\times \\
u &\mapsto \chi(A_u).
\end{align*}
If $A_u$ and $B_u$ are two unit lifts of the same class $u$, then $A_uB_u^{-1}\equiv 1\pmod m$ in the unit group modulo $q$, so the assumed invariance gives $\chi(A_uB_u^{-1})=1$. Hence $\chi(A_u)=\chi(B_u)$, and $\psi$ is well-defined. It is multiplicative because $\chi$ is multiplicative on unit classes. The restriction of $\chi$ to $(\mathbb Z/q\mathbb Z)^\times$ therefore factors through the reduction map
\begin{align*}
(\mathbb Z/q\mathbb Z)^\times\to(\mathbb Z/m\mathbb Z)^\times.
\end{align*}
Equivalently, $\chi$ is induced from the character $\psi$ modulo $m$: on unit classes modulo $q$ it is obtained by reducing modulo $m$, and on non-units modulo $q$ it is zero by the definition of a Dirichlet character modulo $q$. Thus $\chi$ is induced from modulus $m<q$, contradicting primitivity. Therefore such an $a$ exists.
[/proof]
Because $d \mid n$ and $m=q/d \mid a-1$, we have $q \mid n(a-1)r$ for every $r \in \mathbb{Z}$. Hence
\begin{align*}
e_q(nar)=e_q(nr)
\end{align*}
for every $r \in \mathbb{Z}$. Multiplication by $a$ permutes the residue classes modulo $q$, so
\begin{align*}
\widehat{\chi}(n)
&= \sum_{r=1}^{q}\chi(ar)e_q(nar) \\
&= \chi(a)\sum_{r=1}^{q}\chi(r)e_q(nr) \\
&= \chi(a)\widehat{\chi}(n).
\end{align*}
Since $\chi(a)\ne 1$, this forces $\widehat{\chi}(n)=0$. Also $\chi(n)=0$ because $\gcd(n,q)>1$, so
\begin{align*}
\widehat{\chi}(n)=0=\overline{\chi}(n)\tau(\chi).
\end{align*}
Thus the identity holds for all $n \in \{1,\dots,q\}$.[/step]