Let $(C, J)$ be a small site and let $\mathsf{Sh}\_{(2, 1)}(C, J)$ be the $(2, 1)$-sheaf topos of sheaves of (small) groupoids on $(C, J)$. Let $G$ be a sheaf of groups on $(C, J)$, and let $\mathbf{Bun}\_G$ be the hom-stack $[-, \mathbf{B}G]$, which is typically known as the moduli stack of principal $G$-bundles on $(C, J)$. [On the nLab](https://ncatlab.org/nlab/show/principal+bundle#in_terms_of_fiber_sequences), it is stated that (up to homotopy equivalences), principal $G$-bundles over a given base space $X \in (C, J)$, (i.e. objects of $\mathbf{Bun}\_G(X)$) are homotopy pullbacks of the following form:


$\require{AMScd}$
\begin{CD}
P @>>> \*\\
@V V V @VV V\\
X @>>> \mathbf{B}G
\end{CD}


Would anyone mind explaining to me why this is the case, and moreover, how one might obtain "local trivialisations" out of the above pullback square ? The nLab article I linked does go into these topics, but their explanation is a bit too abstract non-sensical for me to be able to cut through.



Internal principal $G$-bundles
The easiest way to see local trivializations is to compute the homotopy pullback using the local projective model structure.


For differential geometry, we can $C$ to be the category of cartesian spaces and smooth maps, whereas $J$ is the usual topology of open covers.
(Other sites work in the same manner.)


Then maps $\def\B{{\bf B}} X→\B G$ in the homotopy category
correspond to maps $Č(U)→\B G$ of presheaves of groupoids,
where $U$ is a good cover of $X$ and $Č(U)$ denotes the Čech nerve of U.


Unfolding this construction, we see that a map $Č(U)→\B G$


* sends each $U\_i$ to the only object of $\B G(U\_i)$;
* sends each intersection $U\_i ∩ U\_j$ to a morphism in $\B G(U\_i∩U\_j)$, i.e., a smooth map $t\_{i,j}\colon U\_i∩U\_j→G$;
* for each triple intersection $U\_i∩U\_j∩U\_k$, it enforces a cocycle condition $t\_{j,k}t\_{i,j}=t\_{i,k}$.


This data is precisely the traditional description of principal $G$-bundles in terms of cocycles.


Next, we can compute the homotopy pullback by replacing the map $\*→\B G$ with a fibration, namely, $\def\E{{\bf E}} \E G→\B G$,
where $\E G(V)$ is the nerve of the contractible groupoid with its objects being smooth maps $V→G$.


Let's now see what a smooth map $V→P$, i.e., an element of $P(V)$ is in concrete terms.
By definition of a pullback, an element of $P(V)$ can be described
as a pair $(b,f)$, where $b∈Č(U)(V)$, i.e., a smooth map $V→U\_i$ for some $i$, whereas $f∈\E G(V)$, i.e., a smooth map $V→G$.
The pullback compatibility condition for objects is trivial because $\B G(V)$ has a single object.


Thus, restricting our attention to a single $U\_i⊂X$, we see that
maps $V→P$ are pair of smooth maps $(b\colon V→U\_i,f\colon V→G)$,
or, equivalently, a smooth map $τ\colon V→U\_i⨯G$.
The manifold $U\_i⨯G$ is precisely the total space
of the trivial principal $G$-bundle $U\_i⨯G→U\_i$ over $U\_i$.


Next, let's examine a generic morphism of the form $$(b\colon V→U\_i,f\colon V→G)→(b'\colon V→U\_i,f'\colon V→G).$$
According to the definition of a pullback, such a morphism is given by a compatible pair of morphisms $b→b'$ and $f→f'$.
By definition of $\E G(V)$, there is a unique morphism $f→f'$,
and its image in $\B G(V)$ is $f'f^{-1}$.
By definition of $Č(U)$, a morphism $b→b'$ exists if and only if
$b$ and $b'$ factor through the intersection $U\_i∩U\_j$,
in which case such a morphism is unique and its image
in $\B G(V)$ is $t\_{i,j}$.
Finally, the compatibility condition amounts to saying $f'f^{-1}=t\_{i,j}$.


Collecting all the pieces together, we see that two maps
$(b,f)\colon V→U\_i⨯G$ and $(b',f')\colon V→U\_j⨯G$ are identified if they satisfy the relation $f'f^{-1}=t\_{i,j}$.
This is precisely how the total space of a principal bundle
is glued from individual pieces given by trivial principal bundles over $U\_i$ and $U\_j$.


Thus, a map $c\colon X→\B G$ picks out principal $G$-bundles,
and for such a map, the homotopy pullback is precisely the total space of the principal $G$-bundle classified by $c$.


