Classification of principal $G$-bundles over closed oriented surfaces with $G$ connected. Let $\Sigma$ be a closed oriented surface and $G$ a connected Lie group. Then, it is known that

principal $G$-bundles $P\to\Sigma$ are topologically classified by a characteristic class $c(P)\in  H^2(\Sigma,\pi_1 G)\cong\pi_1 G$.

So, why is this true? Any reference? Thanks.
 A: I don't know of a reference, but this follows from classifying space theory and a bit of homotopy theory. (Having written the answer, I now realise there is probably an easier answer using obstruction theory.)
Let $G$ be a topological group, then there is a topological space $BG$ and a principal $G$-bundle $EG \to BG$, called the universal principal $G$-bundle. It is so called because for any principal $G$-bundle over a paracompact space $X$, there is a map (unique up to homotopy) $f : X \to BG$ such that $f^*EG \to X$ is isomorphic to the given principal $G$-bundle. The universal bundle is uniquely determined (up to isomorphism) by the fact that $EG$ is weakly contractible. 
It follows that the isomorphism classes of principal $G$-bundles, denoted $\operatorname{Prin}_G(X)$, are in one-to-one correspondence with homotopy classes of maps $X \to BG$, denoted $[X, BG]$. In particular, for the case you asked about, we have $\operatorname{Prin}_G(\Sigma) = [\Sigma, BG]$.
The long exact sequence in homotopy applied to the universal principal $G$-bundle $EG \to BG$ gives
$$\dots \pi_{n+1}(EG) \to \pi_{n+1}(BG) \to \pi_n(G) \to \pi_n(EG) \to \dots$$
As $EG$ is weakly contractible, we see that $\pi_{n+1}(BG) = \pi_n(G)$.
If $X$ is an $n$-dimensional CW complex and $Y$ is a CW complex, then it follows from the cellular approximation theorem that $[X, Y] = [X, Y^{(n+1)}]$ where $Y^{(n+1)}$ denotes the $(n+1)$-skeleton of $Y$. If $X$ and $Y$ are pointed, then the same is true of basepoint-preserving homotopy classes. In particular, $\pi_n(Y) = \pi_n(Y^{(n+1)})$.
You can attach cells on to $BG$ of dimension at least four so that the resulting space, call it $Z$, has $\pi_n(Z) = 0$ for $n \geq 3$ (attach an $(n + 1)$-cell for each generator of $\pi_n(BG)$)*. Moreover, because the cells that were added were of dimension at least five, $Z$ has the same $3$-skeleton as $BG$. Again by cellular approximation, $\pi_2(Z) = \pi_2(Z^{(3)}) = \pi_2(BG^{(3)}) = \pi_2(BG) = \pi_1(G)$ (note, this implies $\pi_1(G)$ is abelian), and likewise $\pi_1(Z) = \pi_1(BG) = \pi_0(G) = 0$ as $G$ is connected. Therefore $Z$ is an Eilenberg-MacLane space, namely $Z = K(\pi_1(G), 2)$.
The identity map $\operatorname{id} : \pi_1(G) \cong \pi_2(K(\pi_1(G), 2)) \cong H_2(K(\pi_1(G), 2); \mathbb{Z}) \to \pi_1(G)$ gives rise to an element of $\operatorname{Hom}(H_2(K(\pi_1(G), 2); \mathbb{Z}), \pi_1(G))$ and hence** to an element $\alpha \in H^2(K(\pi_1(G), 2); \pi_1(G))$. For any $[g] \in [\Sigma, K(\pi_1(G), 2)]$, $[g] \mapsto g^*\alpha \in H^2(\Sigma; \pi_1(G))$ defines a bijection $[\Sigma, K(\pi_1(G), 2)] \to H^2(\Sigma; \pi_1(G))$, so we see that
$$\operatorname{Prin}_G(\Sigma) = [\Sigma, BG] = [\Sigma, BG^{(3)}] = [\Sigma, Z^{(3)}] = [\Sigma, Z] = [\Sigma, K(\pi_1(G), 2)] = H^2(\Sigma; \pi_1(G)).$$
We have an inclusion $\iota : BG \to K(\pi_1(G), 2)$. The overall isomorphism $[\Sigma, BG] \to [X, K(\pi_1(G), 2)]$ is given by $[f] \mapsto [\iota\circ f]$. Therefore the isomorphism $[\Sigma, BG] \to H^2(\Sigma; \pi_1(G))$ is given by $[f] \mapsto (\iota\circ f)^*\alpha = f^*(\iota^*\alpha) = f^*\beta$ where $\beta := \iota^*\alpha \in H^2(BG; \pi_1(G))$. 
If $P \to \Sigma$ is a principal $G$-bundle, then $c(P) \in H^2(\Sigma; \pi_1(G))$ is given by $c(P) = f^*\beta$ where $f : \Sigma \to BG$ is a classifying map for $P$.
As $\Sigma$ is closed and oriented, $H^2(\Sigma; \pi_1(G)) \cong \pi_1(G)$; in fact, you only need $\Sigma$ to be orientable for this to hold. For certain groups $\pi_1(G)$ (e.g. $\mathbb{Z}_2^k$), the isomorphism still holds even in the non-orientable case. If $\Sigma$ is not closed, then $\Sigma$ is homotopy equivalent to a bouquet of circles, so $H^2(\Sigma; \pi_1(G)) = 0$ and hence all principal $G$-bundles over $\Sigma$ are trivial.

If one assumes that $G$ is also simply connected, then the same argument can be used to show that principal $G$-bundles $P \to M$ where $M$ is a manifold (or even just a CW complex) of dimension up to four are classified by a characteristic class $c(P) \in H^4(M; \pi_3(G))$. For example, in this answer the above argument is applied when $G = SU(2)$ and the characteristic class $c(P)$ is identified as $c_2(P)$ (or possibly $-c_2(P)$).

*In fact, $\pi_3(BG) = \pi_2(G) = 0$ as the second homotopy group of a Lie group is always zero, so we don't even need to add any four-dimensional cells and hence $Z$ and $BG$ have the same $4$-skeleton (not that we need this fact).
**Here we are using the fact that $\pi_1(G)$ is abelian, and therefore a $\mathbb{Z}$-module, so we can use the Universal Coefficient Theorem for cohomology.
