Lifting the classyfing map and characteristic classes This question was originally posted on mathoverfow: below the question there were some useful comments however no canonical answer was given. Normally I would offer a bounty for this question but it was voted +3-2 so probably was not well suited for mathoverflow. This is the reason why I'm posting it here. So here is the question:  
Let $E$ be an $n$-plane bundle over CW complex $X$. Then $E$ is a pullback of tautological bundle $\gamma_n$ over $BO(n)$ i.e. $E=f^*(\gamma_n)$. This $f$ is called classyfing map. One can show that the universal covering of $BO(n)$ is $BSO(n)$ and $f$ can be lifted to $BSO(n)$ (meaning that there is $\tilde{f}:X \to BSO(n)$ such that $p \circ \tilde{f}=f$ where $p$ is the projection) if and only if $f_*:\pi_1(X) \to \pi_1(BO(n)) \cong \mathbb{Z}_2$ is zero. Such a map from $\pi_1(X)$ to $\mathbb{Z}_2$ gives rise to the cohomology class in $H^1(X,\mathbb{Z}_2)$.  
One can also show that the $2$-connected covering of $BSO(n)$ is $BSpin(n)$ and one can ask for further extensions of the classyfing map to $BSpin(n)$. 

I would like to understand how the existence of such extension is equivalent to the vanishing of some class in $H^2(X,\mathbb{Z}_2)$.   

I know that this class should be exactly the second Stiefel-Whitney class and I would also like to understand: 

Why this class is the second Stiefel-Whitney class?  

 A: The keyword to look up is obstruction theory, and the story goes like this.
First let me describe a simpler but analogous story about groups. Suppose $f : G \to H$ is a map of groups, and you want to understand when this map can be lifted to a map $G \to K$, where $K \subseteq H$ is a subgroup. (It might sound a bit strange to call such a thing a lift, but bear with me.) If $K$ is a normal subgroup, there's a nice answer: there is a short exact sequence
$$0 \to K \to H \xrightarrow{q} H/K \to 0$$
exhibiting $K$ as the kernel of a map, namely the quotient map $H \xrightarrow{q} H/K$, and by the universal property of kernels, $f$ lifts to $K$ iff the composite map
$$G \xrightarrow{f} H \xrightarrow{q} H//K$$
is zero.
The story in homotopy theory is a categorification of this story. Now suppose $f : X \to E$ is a map of spaces, and you want to understand when this map can be lifted to a map $X \to F$, where $F$ is some space equipped with a map $F \to E$, up to homotopy. When $E = BG$ for a group $G$ and $F = B \widetilde{G}$ for some group $\widetilde{G}$ equipped with a map $\widetilde{G} \to G$ giving such a lift is called reducing the structure group of the $G$-bundle $f : X \to BG$ from $G$ to $\widetilde{G}$, and includes as a special case finding orientations, spin structures, almost complex structures, etc.
The answer to this question is nicest if the map $F \to E$ is a "homotopy kernel" in the sense that it is part of a fiber sequence
$$F \to E \xrightarrow{q} B.$$
Here $F, E, B$ are pointed spaces and this is a sequence of pointed maps, and being part of a fiber sequence means $F$ is the homotopy fiber of the map $E \to B$, which means precisely that it satisfies the following universal property: a map $f : X \to E$ lifts to a map $X \to F$ up to homotopy if and only if the composite map
$$X \xrightarrow{f} E \xrightarrow{q} B$$
is nullhomotopic (homotopic to the map $X \to B$ sending every point in $X$ to the basepoint of $B$).

General fact: Let $E$ be $(n-1)$-connected and let $\widetilde{E}$ be its $n$-connected cover. There is a unique map (up to homotopy) $q : E \to B^n \pi_n(E) \cong K(\pi_n(E), n)$ inducing the identity on $\pi_n$, and it fits into a fiber sequence
$$\widetilde{E} \to E \xrightarrow{q} B^n \pi_n(E).$$
In other words, a map $f : X \to E$ lifts to a map $f : X \to \widetilde{E}$ up to homotopy if and only if the composite $X \xrightarrow{f} E \xrightarrow{q} B^n \pi_n(E)$ is nullhomotopic, or equivalently if and only if the cohomology class $f^{\ast}(q) \in H^n(X, \pi_n(E))$ is zero.

When $E = BO(n)$ this recovers the usual story about $w_1$ and orientations, basically because $w_1$ is the unique nontrivial map $BO(n) \to B \mathbb{Z}_2$ up to homotopy. Similarly when $E = BSO(n)$ this recovers the usual story about $w_2$ and spin structures, because $w_2$ is the unique nontrivial map $BSO(n) \to B^2 \mathbb{Z}_2$ up to homotopy (both of these are straightforward corollaries of the Hurewicz theorem + universal coefficients).
What is a bit surprising here is that $w_2$ is already defined on $BO(n)$, but the story doesn't continue this way: the next step is about string structures and is controlled by a class $\frac{p_1}{2} \in H^4(BSpin(n), \mathbb{Z})$ called the first fractional Pontryagin class which is not the pullback of a cohomology class on $BSO(n)$ (here I need $n \ge 4$ or maybe $n \ge 5$, not sure).
