Skip to content

Commit 3323e3c

Browse files
committed
feat: force option for cli auth
1 parent 0e02070 commit 3323e3c

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

src/uipath/_cli/cli_auth.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import socket
55
import webbrowser
6+
from typing import Optional
67

78
import click
89
from dotenv import load_dotenv
@@ -56,25 +57,34 @@ def set_port():
5657

5758
@click.command()
5859
@environment_options
59-
def auth(domain="alpha"):
60+
@click.option(
61+
"-f",
62+
"--force",
63+
is_flag=True,
64+
required=False,
65+
help="Force new token",
66+
)
67+
def auth(domain, force: Optional[bool] = False):
6068
"""Authenticate with UiPath Cloud Platform."""
6169
with console.spinner("Authenticating with UiPath ..."):
6270
portal_service = PortalService(domain)
63-
if (
64-
os.getenv("UIPATH_URL")
65-
and os.getenv("UIPATH_TENANT_ID")
66-
and os.getenv("UIPATH_ORGANIZATION_ID")
67-
):
68-
try:
69-
portal_service.ensure_valid_token()
70-
console.success(
71-
"Authentication successful.",
72-
)
73-
return
74-
except Exception:
75-
console.info(
76-
"Authentication token is invalid. Please reauthenticate.",
77-
)
71+
72+
if not force:
73+
if (
74+
os.getenv("UIPATH_URL")
75+
and os.getenv("UIPATH_TENANT_ID")
76+
and os.getenv("UIPATH_ORGANIZATION_ID")
77+
):
78+
try:
79+
portal_service.ensure_valid_token()
80+
console.success(
81+
"Authentication successful.",
82+
)
83+
return
84+
except Exception:
85+
console.info(
86+
"Authentication token is invalid. Please reauthenticate.",
87+
)
7888

7989
auth_url, code_verifier, state = get_auth_url(domain)
8090

0 commit comments

Comments
 (0)