Finite group action induces an isomorphism of G-invariants I am having trouble with the following exercise (exercise 12.9 in the book Algebraic geometry I by Ulrich Görtz and Torsten Wedhorn).

Let $A$ and $B$ be commutative $R$-algebras, where $R$ is a commutative ring. Let $G$ be a finite group with $n$
elements, and suppose $n \in R^\times$. Let $G$ be acting on $A$. Show that the natural morphism $$\iota_B : B \otimes A^G \to (B \otimes_R A)^G$$ is an isomorphism. Here, $A^G$ denotes the subring of $G$-invariant elements, or equivalently, the kernel of $A \to \prod_{g \in G} A$, $a \mapsto (g(a) - a)_{g \in G}$.

I don't even know how to attack this problem. The fact that $n \in R^\times$ gives a morphism of $R$-modules
$$ \zeta: B \otimes_R A \to (B \otimes_R A)^G, \quad b \mapsto n^{-1} \sum_{g\in G} g(b),$$
but I doubt this is of any use. I also don't want to lose myself in messy calculations, but I don't know how to otherwise deal with the tensor products. Any help would be appreciated!
 A: This also holds for modules. And your idea to use the "averaging map" indeed leads to a proof.
Let $R$ be a commutative ring and let $M,N$ be two $R$-modules. Let $G$ be a finite group of order $n$ acting on $M$ such that $n \in R^{\times}$. Then the canonical map (tensor products are over $R$)
$$M^G \otimes N \to (M \otimes N)^G$$
is an isomorphism. The problem here is that $M^G$ is a kernel, but the tensor product is only right exact. The trick is to write $M^G$ as a cokernel instead, for which the assumption $n \in R^{\times}$ is crucial. Consider the linear map
$$\pi_M: M \to M, ~ x \mapsto \frac{1}{n} \sum_{g \in G} gx.$$
Then $\pi_M$ is a projection onto $M^G$. Thus,
$$M^G = \mathrm{im}(\pi_M) \cong M/\ker(\pi_M) = M/\mathrm{im}(\mathrm{id} - \pi_M) = \mathrm{coker}(\mathrm{id} - \pi_M).$$
Since the tensor product is right exact, we get
$$M^G \otimes N \cong \mathrm{coker}(\mathrm{id} \, - \, \pi_M \otimes N).$$
But it is evident that
$$\pi_M \otimes N = \pi_{M \otimes N},$$
and hence we get $M^G \otimes N \cong (M \otimes N)^G$ as desired. It is easy to verify that this isomorphism is actually the canonical homomorphism.
