Refactor createAccessTokenFromPassword()

Split up what it does into separate methods and also tidy up some
whitespace issue in this file.