Refactored login api client versions to reuse common state-setting code.