First, I think there is a typo in the book: the $a$'s should be $\alpha$'s in the second term of $S_c$. Otherwise, those quantities are just out of place.
Start by focusing on a single $q_\alpha$. Your bath action and the coupling bit for a single $q_\alpha$ is
$$
S_\alpha = \int_0^t dt'\frac{m_\alpha}{2}\left[\dot{q}_\alpha^2(t') - \omega^2_\alpha q_\alpha^2(t')\right] - f_\alpha(t') q_\alpha(t')\,.
$$
Note that we explicitly included the $t'$ in the expression for book-keeping.
We want to integrate
$$
\int Dq_\alpha \,e^{iS_\alpha}\,.
$$
There are a few ways to go from here. I would prefer to keep everything in the time domain, but A&S are smart, so let's follow their approach! First, we do $t \rightarrow - i\tau$. This means that $dt' \rightarrow -i d\tau'$ and $dq_\alpha /dt\rightarrow idq_\alpha/d\tau$. This gives
$$
S_\alpha = -i\int_0^\tau d\tau'\frac{m_\alpha}{2}\left[-\dot{q}_\alpha^2(\tau') - \omega^2_\alpha q_\alpha^2(\tau')\right] - f_\alpha(\tau') q_\alpha(\tau')\,.
$$
Setting the upper integration limit to $\beta$, we have
$$
S_\alpha = i\int_0^\beta d\tau'\frac{m_\alpha}{2}\left[\dot{q}_\alpha^2(\tau') + \omega^2_\alpha q_\alpha^2(\tau')\right] + f_\alpha(\tau') q_\alpha(\tau')\,.
$$
Because we assume that $q_\alpha(0) = q_\alpha(\tau)$, we can integrate the first term by parts to get
$$
S_\alpha = i\int_0^\beta d\tau'\frac{m_\alpha}{2}\left[-q_\alpha(\tau')\ddot{q}_\alpha(\tau') + \omega^2_\alpha q_\alpha^2(\tau')\right] + f_\alpha(\tau') q_\alpha(\tau')\,.
$$
Using $q_\alpha(\tau') = \sum_n q_\alpha(\omega_n)e^{i\omega_n\tau} $ and $\ddot{q}_\alpha(\tau') = -\sum_n \omega_n^2q_\alpha(\omega_n)e^{i\omega_n\tau} $, we get
$$
S_\alpha = i\int_0^\beta d\tau'\frac{m_\alpha}{2}\sum_{nn'}\left[\omega_n^2 + \omega^2_\alpha \right]
q_\alpha(\omega_n)e^{i\omega_n\tau'}q_\alpha(\omega_{n'})e^{i\omega_{n'}\tau'}
+i\int_0^\beta d\tau' f_\alpha(\tau') \sum_n q_\alpha(\omega_n)e^{i\omega_n\tau'}
\\
= i\beta\frac{m_\alpha}{2}\sum_{nn'}\left(\omega_n^2 + \omega^2_\alpha \right)
q_\alpha(\omega_n)q_\alpha(\omega_{n'})\delta_{n,-n'}
+\frac{i}{T} \sum_n f_\alpha(-\omega_n) q_\alpha(\omega_n)
\\
= i\beta\frac{m_\alpha}{2}\sum_{n}\left(\omega_n^2 + \omega^2_\alpha \right)
q_\alpha(\omega_n)q_\alpha(-\omega_{n})
+\frac{i}{T} \sum_n f_\alpha(-\omega_n) q_\alpha(\omega_n)
\,.
$$
OK, almost there. To make the integrals nicer, we write
$$
S_\alpha
= i\beta\frac{m_\alpha}{2}\sum_{n>0}\left(\omega_n^2 + \omega^2_\alpha \right)
\left[q_\alpha(\omega_n)q_\alpha(-\omega_{n})+q_\alpha(-\omega_n)q_\alpha(\omega_{n})\right]
+\frac{i}{T} \sum_{n>0} f_\alpha(-\omega_n) q_\alpha(\omega_n)+f_\alpha(\omega_n) q_\alpha(-\omega_n)
\\
=
i\sum_{n>0}
\begin{pmatrix}
q_\alpha(\omega_n) & q_\alpha(-\omega_n)
\end{pmatrix}
\begin{pmatrix}
0&\frac{\beta m_\alpha}{2}(\omega_n^2 + \omega_\alpha^2)
\\
\frac{\beta m_\alpha}{2}(\omega_n^2 + \omega_\alpha^2)&0
\end{pmatrix}
\begin{pmatrix}
q_\alpha(\omega_n) \\ q_\alpha(-\omega_n)
\end{pmatrix}
+
\frac{1}{T}\begin{pmatrix}
f_\alpha(\omega_n) & f_\alpha(-\omega_n)
\end{pmatrix}
\begin{pmatrix}
q_\alpha(\omega_n) \\ q_\alpha(-\omega_n)
\end{pmatrix}
\\
=
i\sum_{n>0}
\frac{1}{2}\mathbf{q}_{n\alpha}^T
\begin{pmatrix}
0&W_n
\\
W_n&0
\end{pmatrix}
\mathbf{q}_{n\alpha}
+
\begin{pmatrix}
f_\alpha(\omega_n)/T & f_\alpha(-\omega_n)/T
\end{pmatrix}
\mathbf{q}_{n\alpha}\,.
$$
This looks like a regular Gaussian integral. Exponentiating $iS_\alpha$ and integrating over $\mathbf{q}_{n\alpha}$ gives something divergent. However, the stuff inside the exponential is OK and that's what we care about:
$$
N\prod_{n>0}
\exp\left[
\frac{f(-\omega_n)f(\omega_n)}{T^2W_n}\right]=N\prod_{n>0}
\exp\left[
\frac{f(-\omega_n)f(\omega_n)}{Tm_\alpha(\omega_n^2+\omega_\alpha^2)}\right]
=N
\exp\left[\sum_n
\frac{ f(-\omega_n)f(\omega_n)}{2Tm_\alpha(\omega_n^2+\omega_\alpha^2)}\right]\,.
$$
To get the expression in the book, take the second part of $S_c$, Fourier transform it and add it to the stuff inside the exponential. Finally, multiply the contributions from all the $\alpha$'s together.