Suppose we have a central mass $M$ and a smaller mass $m$ orbiting around the central mass in an ellipse:
The other point is the other focus. We know that elliptical orbits have the central mass in one of the two foci of the ellipse, I put the other one to emphasize this fact.
Also I know that in the case of the circle the formula is easy to derive. $a_c = \frac{v^2}{r}$, in other words the velocity needs to be such that its magnitude squared over the radius is equal to the centripetal acceleration, and its direction perpendicular to the acceleration. If there is any other component to the velocity, it would stop being in a uniform or circular orbit. I know from the law of universal gravitation that the centripetal acceleration is $a_c = \frac{\frac{GMm}{r^2}}{m} = \frac{GM}{r^2}$ If we put that into $a_c = \frac{v^2}{r}$, we get
$$ \frac{GM}{r^2} = \frac{v^2}{r} $$ $$ \therefore v = \sqrt{\frac{GM}{r}}$$
However for the ellipse, how can we conclude that the velocity needs to be $\sqrt{\frac{GM}{r}}$ at any point? We can't make the assumption that $a_c = \frac{v^2}{r}$ because we are no longer considering uniform circular motion. What can be done?