Equivalence of two definitions of Spin structure Let $\xi$ denote a principal firbe bundle with structure group $SO(n)$. The total space of $\xi$ will be denoted by $E(\xi)$ and the base space by $B$ where $B$ is a manifold.
Definition 1 : A spin structure on $\xi$ is a pair $(\eta,f)$ consisting of 


*

*A principal bundle $\eta$ over $B$ with structure group $\text{Spin }(n)$

*A map $f:E(\eta)\to E(\xi)$ such that the following diagrams commute 
$\require{AMScd}$
\begin{CD}
    E(\eta)\times\text{Spin }(n) @>\text{right translation}>> E(\eta)@>>> B\\
    @V f\,\times\,\lambda V V @VV f V @|\\
    E(\xi)\times SO(n) @>\text{right translation}>> E(\xi)@>>> B
\end{CD} 
Here $\lambda$ denotes the standard homomorphism from $\text{Spin }(n)$ to $SO(n)$.
A second spin structure $(\eta',f')$ on $\xi$ should be identified with $(\eta,f)$ if there exists an isomorphism $g:\eta'\to\eta$ so that $f\circ g=f'$
Definition 2: A spin structure on $\xi$ is a cohomology class $\sigma\in H^1(E(\xi),\mathbb Z_2)$ whose restriction to each fibre, $F$ is a generator of the cyclic group $H^1(F,\mathbb Z_2)$.

My Question : How are these two definitions equivalent?

Milnor gives the following idea - 

Any such cohomology class determines a 2-fold covering of $E(\xi)$. This covering space is to be taken as the total space $E(\eta)$. The condition on $\sigma|_F$ guarantees that each fibre is covered by a copy of $\text{Spin }(n)$, the unique 2 fold covering of $SO(n)$.

But I am not clear with the details -


*

*How does $\sigma$ determine a 2-fold covering?

*Why does the condition on $\sigma|_F$ guarantee that each fibre is covered by a copy of $\text{Spin }(n)$?
Thank you.
 A: Every cohomology class $\xi \in H^1(Y;\Bbb Z/2)$ classifies an $O(1)$-bundle. Thus if you have $\eta \in H^1(E(\xi);\Bbb Z/2)$, that gives a double cover of $E(\xi)$. Then the demand that $\eta$ restrict to the generator of $H^1(F;\Bbb Z/2)$ over each fiber says that this double cover over $SO(n)$ is connected; aka, it is the universal cover. This is again because $H^1(Y;\Bbb Z/2)$ classifies double covers, and the class given is not zero. (When $n=2$, it is not the universal cover, but it is connected.) There is thus a natural action of $\text{Spin}(n)$ on this double cover - if we denote the nonzero element of $\text{Spin}(n)$ in the fiber over $I$ as $s$, then it is the unique action such that $s$ is the deck transformation corresponding to the double cover, and such that when passing to the appropriate action down below, it's the same as the old $SO(n)$-action. So this does give a $\text{Spin}(n)$-bundle that maps to the $SO(n)$-bundle. 
Conversely a spin structure in your first sense double covers $E(\xi)$, which provides a cohomology class in $H^1(Y;\Bbb Z/2)$, and because the double cover of each fiber is connected, this restricts as it should.
