Fix auth commands
@@ -9,7 +9,6 @@ from polyaxon_schemas.authentication import AccessTokenConfig, CredentialsConfig
from polyaxon_schemas.polyaxonfile.logger import logger
from polyaxon_cli.managers.auth import AuthConfigManager
-from polyaxon_cli.managers.config import GlobalConfigManager
from polyaxon_cli.utils.clients import PolyaxonClients
@@ -19,6 +18,7 @@ from polyaxon_cli.utils.clients import PolyaxonClients
@click.option('--password', '-p', help='Polyaxon password')
def login(token, username, password):
"""Log into Polyaxon."""
+ auth_client = PolyaxonClients().auth
if username:
# Use username / password login
if not password:
@@ -30,13 +30,13 @@ def login(token, username, password):
sys.exit(1)
credentials = CredentialsConfig(username=username, password=password)
- access_code = PolyaxonClients().auth.login(credentials=credentials)
+ access_code = auth_client.login(credentials=credentials)
if not access_code:
logger.info("Failed to login")
return
-
+ else:
if not token:
- cli_info_url = "{}/users/token".format(GlobalConfigManager.get_value('host'))
+ cli_info_url = "{}/users/token".format(auth_client.http_host)
click.confirm('Authentication token page will now open in your browser. Continue?',
abort=True, default=True)
@@ -52,6 +52,7 @@ def login(token, username, password):
return
access_code = access_code.strip(" ")
+
user = PolyaxonClients().auth.get_user(token=access_code)
access_token = AccessTokenConfig(username=user.username, token=access_code)
AuthConfigManager.set_config(access_token)
