This result is better understood in terms of automorphic representations. Let $F$ be an algebraic number field, and let $\pi$ be an automorphic representation of $\mathrm{GL}_2\left(\mathbb{A}_F\right)$, where $\mathbb{A}_F$ denotes the ring of adèles of $F$.
Suppose that there exists a nontrivial unitary Hecke character $\omega$ of $F^{\times} \backslash \mathbb{A}_F^{\times}$ such that $\pi \otimes (\omega \circ \det) \cong \pi$. Then $\omega$ must necessarily be quadratic, and the representation $\pi$ is said to be a monomial representation. This is what you call CM, but this labelling only really makes sense when $F = \mathbb{Q}$ and $\pi$ corresponds to a holomorphic modular form, for the reasons outlined in Ribet's paper. When $\pi$ corresponds to a Maaß form, I have seen such form called of CM-type, but this seems a little incongruous.
Let $E$ be the quadratic extension of $F$ associated to $\omega$ via class field theory. Then the following statement is Proposition 6.5 of L-indistinguishability for $\mathrm{SL}(2)$ by Labesse and Langlands:
If $\pi$ is a monomial automorphic representation, then there exists a Hecke character $\chi$ of $E^{\times} \backslash \mathbb{A}_E^{\times}$ such that $\pi \cong \pi(\chi)$.
Here $\pi(\chi)$ denotes the cuspidal automorphic representation of $\mathrm{GL}_1\left(\mathbb{A}_E\right)$ associated to $\chi$.
While I do not believed it is mentioned in this paper, it is worth noting the following:
The monomial automorphic representation $\pi$ is cuspidal if and only if $\chi$ does not factor through the norm map (that is, there does not exist some Hecke character $\widetilde{\chi}$ of $F^{\times} \backslash \mathbb{A}_F^{\times}$ for which $\chi = \widetilde{\chi} \circ N_{E/F}$).
The proof of these results involve automorphic representations instead of Galois representations, and in particular generalise to Maaß forms (when $F = \mathbb{Q}$ and $\pi_{\infty}$ is a principal series representation) and Hilbert modular forms (when $F$ is a totally real field and $\pi_v$ is a discrete series representation for each archimedean place $v$).