Let G be a Lie group and M a smooth manifold. Suppose that P is a principal G-bundle over M. Then by Yoneda, this corresponds to a smooth map $p:M \to [G]$, where $[G]$ is the differentiable stack associated to G. If P is equipped with a connection, how does this fit in this picture?

I was thinking of using the fact that we can obtain $P$ as the weak pullback of the classifying map p along the universal principal G-bundle $* \to [G]$, and then using that the tangent functor preserves finite weak limits. Then, if we are given a connection in terms of a G-invariant subbundle of $TP$, we could express its inclusion map $H \to TP$ as a map $H \to TM$ together with a certain 2-cell between the composite of the canonical map $H \to [TG]$ (the universal TG-bundle composed with the unique map to the terminal object) and T(p) composed with $H \to TM$. But then of course, we need to put conditions on our map $H \to TM$ to make sure that the induced map $H \to TP$ is an inclusion of vector bundles that moreover defines a G-invariant Ehresmann connection. Maybe this is not the way to go...

Does anyone know of a nice way of encoding a connection in this stacky language?