Auto detect the current endpoint when logging in

Since refresh tokens haven't been implemented yet, I felt it important
to streamline the login process. Rather than always defaulting
`force login` to production, it will instead default it to whatever the
current endpoint is.

Note that the other changes here are from the old master before history was rewritten. If you don't want them remerged, I can revert them on my master branch and resubmit this.