Let $G$ be a (complex) Lie group, $\mathfrak{g}$ its Lie algebra. Consider a central extension $\hat{\mathfrak{g}}$ of $\mathfrak g$ by a one-dimensional trivial module $$0 \to \mathbb C \to \hat{\mathfrak g} \to \mathfrak g \to 0.$$ It corresponds to some cocycle $\theta \in Hom(\Lambda^2\mathfrak g, \mathbb C)$.
On the level of Lie groups one gets a locally trivial fibration. Since its fiber is commutative, one can think about $\hat{G} = Lie(\hat{\mathfrak g})$ as the total space of some vector bundle on $G$ of rank 1.
So my question is: how can I find an affine connection on this bundle such that it curvature form would be exactly the characteristic cocycle $\theta$ (viewed as invariant 2-form on $G$)?