  We compute the class of the classifying stack of the exceptional algebraic
group $G_2$ and of the spin groups $\mathrm{Spin}_7$ and $\mathrm{Spin}_8$ in
the Grothendieck ring of stacks, and show that they are equal to the inverse of
the class of the corresponding group. Furthermore, we show that the computation
of the motivic classes of the stacks $\mathscr{B}\mathrm{Spin}_n$ can be
reduced to the computation of the classes of $\mathscr{B} \Delta_n$, where
$\Delta_n\subset \mathrm{Pin}_n$ is the "extraspecial $2$-group", the preimage
of the diagonal matrices under the projection $\mathrm{Pin}_n\to \mathrm{O}_n$
to the orthogonal group.
