This is exercise 7.7.4 of Weibel's an introduction to homological algebra. Let $\mathfrak{g}$ be a Lie algebra over a ring $k$. Let $0\to M\xrightarrow{i} N\xrightarrow{\pi} k\to 0$ be a short exact sequence of $\mathfrak{g}$-modules, and $n\in N$ is such that $\pi(n)=1$, define $f:\mathfrak{g}\to M$ by $f(x)=i^{-1}(xn)$.
I have shown that $f$ is a 1-cocycle in the Chevalley-Eilenberg complex $\rm{Hom}(\wedge^*(\mathfrak{g},M))$ and that its class $[f]\in H^1(\mathfrak{g},M)$ does not depend on the choice of $n$. I want to show that the map
$$\left\{\mathrm{equivalent~classes~of~extension~of~k~by~M}\right\}\to H^1(\mathfrak{g},M)$$ $$ (0\to M\xrightarrow{i} N\xrightarrow{\pi} k\to 0) \mapsto [f]$$ gives the 1-1 correspondence. But I'm not able to show that this map is one one and onto.
For ontoness, I am not sure how to construct $N$ and the maps $i$ and $\pi$ to get the exactness of the sequence. Can someone please guide me through the proof or provide any relevant hints or resources?