Let $T$ be an algebraic torus and $G$ a diagonalizable group; both are over an algebraically closed field $k$ of characteristic $0$ (take $k=\mathbb C$, if you like).
I am trying to understand principal $G$-bundles $P\to T$ over $T$, but I'm getting conflicting conclusions from two perspectives.
From what I've read (e.g. pg 11-13 here: https://arxiv.org/pdf/2009.08675.pdf), the total space $P$ is given by $$P=\operatorname{Spec}_T\left(\bigoplus_{m\in\Gamma} \mathcal L^{\otimes m}\right)$$ where $\Gamma$ is the character group of $G$ (so $\Gamma$ is a finitely generated abelian group) and $\mathcal L$ is a product of line bundles on $T$ indexed by generators for $\Gamma$ (some possibly torsion, if $\Gamma$ has torsion).
But line bundles on $T$ are all trivial, so $\color{red}{\text{I think we just have (?)}}$
$$\begin{align}\operatorname{Spec}_T\left(\bigoplus_{m\in\Gamma} \mathcal L^{\otimes m}\right) = \operatorname{Spec}_T\left(\bigoplus_{m\in\Gamma} \mathcal O_T^{\otimes m}\right) = \operatorname{Spec}(k[T][\Gamma]) &= \operatorname{Spec}(k[T]\otimes_k k[\Gamma])\\&= T\times G.\end{align}$$
This seems to imply that every principal $G$-bundle over $T$ is trivial.
On the other hand, consider the following example. Take $G=\{1,-1\}$ (i.e. $\mu_2$) as a subgroup of $T=\mathbb G_m$ (rank $1$ torus). Then we have an exact sequence $$1 \to G \to T \xrightarrow{t\mapsto t^2} T \to 1$$ where the map $T\to T$ via $t\mapsto t^2$ is a principal $G$-bundle over $T$. This should not be trivial, since $T\not\cong T\times G$ in this case (i.e. the exact sequence does not split).
This seems to contradict the above approach.
My question is: can anyone explain where I've gone wrong? Is one of the approaches correct and the other incorrect?
Edit: I think in the first approach the $\mathcal O_T$-algebra structure will depend on the torsion in $\Gamma$. For example, if $\Gamma=\mathbb Z/2$, then this $\mathcal O_T$-algebra structure will depend on a choice of isomorphism $\mathcal O_T^{\otimes 2}\to\mathcal O_T$. If this is right, then I guess it comes down to understanding these isomorphisms and how they give different $\mathcal O_T$-algebra structures, which is still confusing to me.
Just to get this off the unanswered list, I will elaborate on my comment above.
Your mistake was in the understanding of the total space of a $\mu_{n,X}$-torsor as $\underline{\mathrm{Spec}}\left(\bigoplus_{i=0}^{n-1}\mathscr{L}^{\otimes i}\right)\to X$ where $\mathscr{L}$ is an $n$-torsion element of $\mathrm{Pic }(X)$. Namely, how are you thinking of a $\bigoplus_{i=0}^{n-1}\mathscr{L}^{\otimes i}$ as a quasi-coherent $\mathscr{O}_X$-algebra? Namely, the multiplication here should be obtained via the natural maps
$$\mathscr{L}^{\otimes a}\otimes \mathscr{L}^{\otimes b}\to \mathscr{L}^{\otimes(a+b)},$$
but, of course, as we only consider $\mathscr{L}^{\otimes i}$ for $i=0,\ldots,n-1$ what you really need is a map like
$$\mathscr{L}^{\otimes a}\otimes \mathscr{L}^{\otimes b}\to \mathscr{L}^{\otimes(a+b\mod n)}.$$
This is doable as $\mathscr{L}^{\otimes n}\cong \mathscr{O}_X$, but not canonically so. In fact, you need to fix an isomorphism $\iota\colon \mathscr{L}^{\otimes n}\xrightarrow{\approx}\mathscr{O}_X$ and then from this structure one can actually give $\bigoplus_{i=0}^{n-1}\mathscr{L}^{\otimes i}$ the structure of a quasi-coherent $\mathscr{O}_X$-algebra.
Let us call this algebra structure $\mathscr{A}(\mathscr{L},\iota)$. Then, one can check that the isomorphism class of $\mathscr{A}(\mathscr{L},\iota)$ only depends on the following equivalence relation on the pair $(\mathscr{L},\iota)$: $(\mathscr{L}_1,\iota_1)\sim (\mathscr{L}_2,\iota_2)$ is there exists an isomorphism $f\colon \mathscr{L}_1\xrightarrow{\approx}\mathscr{L}_2$ such that $\iota_2\circ f^{\otimes n}=\iota_1$. In this way, using $H^1(X,\mu_{n,X})$ to denote the isomorphism classes of $\mu_{n,X}$-torsors, one gets a map
$$\{(\mathscr{L},\iota)\}/\sim\, \longrightarrow\, H^1(X,\mu_{n,X}).$$
This is actually an isomorphism of groups where one defines a group structure on the source in the obvious way: $(\mathscr{L}_1,\iota_1)\otimes (\mathscr{L}_2,\iota_2)=(\mathscr{L}_3,\iota_3)$ where $\mathscr{L}_3=\mathscr{L}_1\otimes\mathscr{L}_2$, and $\iota_3$ is the composition of
$$(\mathscr{L}_1\otimes\mathscr{L}_2)^{\otimes n}\xrightarrow{\text{natural}}\mathscr{L}_1^{\otimes n}\otimes \mathscr{L}_2^{\otimes n}\xrightarrow{\iota_1\otimes\iota_2}\mathscr{O}_X\otimes\mathscr{O}_X\xrightarrow{\text{natural}}\mathscr{O}_X.$$
There are several ways to prove this assertion, let me list two here.