Curvature tensors of higher-spin gauge theories have been known for some time. In the past, they were postulated using a generalization of the symmetry properties of the Riemann tensor (curl on each index of a totally symmetric rank-$n$ field for each spin-$n$). For this reason they are sometimes referred to as the generalized Riemann tensors. In this article, a method for deriving these curvature tensors from first principles is presented; the derivation is completed without any a priori knowledge of the existence of the Riemann tensors or the curvature tensors of higher-spin gauge theories. To perform this derivation, a recently developed procedure for deriving exactly gauge invariant Lagrangian densities from quadratic combinations of $N$ order of derivatives and $M$ rank of tensor potential is applied to the $N = M = n$ case under the spin-$n$ gauge transformations. This procedure uniquely yields the Lagrangian for classical electrodynamics in the $N = M = 1$ case and the Lagrangian for higher derivative gravity (`Riemann and `Ricci squared terms) in the $N = M = 2$ case. It is proven here by direct calculation for the $N = M = 3$ case that the unique solution to this procedure is the spin-3 curvature tensor and its contractions. The spin-4 curvature tensor is also uniquely derived for the $N = M = 4$ case. In other words, it is proven here that, for the most general linear combination of scalars built from $N$ derivatives and $M$ rank of tensor potential, up to $N=M=4$, there exists a unique solution to the resulting system of linear equations as the contracted spin-$n$ curvature tensors. Conjectures regarding the solutions to the higher spin-$n$ $N = M = n$ are discussed.