@@ -80,18 +80,45 @@ def set_port():
8080 required = False ,
8181 help = "Base URL for the UiPath tenant instance (required for client credentials)" ,
8282)
83+ @click .option (
84+ "--no-verify-ssl" ,
85+ "--insecure" ,
86+ is_flag = True ,
87+ required = False ,
88+ help = "Disable SSL certificate verification (not recommended for production)" ,
89+ )
90+ @click .option (
91+ "--cert" ,
92+ required = False ,
93+ type = click .Path (exists = True ),
94+ help = "Path to custom CA certificate bundle file (for corporate certificates)" ,
95+ )
96+ @click .option (
97+ "--proxy" ,
98+ required = False ,
99+ help = "Proxy URL in format: http://proxy:port or https://proxy:port" ,
100+ )
83101@track
84102def auth (
85103 domain ,
86104 force : None | bool = False ,
87105 client_id : str = None ,
88106 client_secret : str = None ,
89107 base_url : str = None ,
108+ no_verify_ssl : bool = False ,
109+ cert : str = None ,
110+ proxy : str = None ,
90111):
91112 """Authenticate with UiPath Cloud Platform.
92113
93114 Interactive mode (default): Opens browser for OAuth authentication.
94115 Unattended mode: Use --client-id, --client-secret and --base-url for client credentials flow.
116+
117+ Network options:
118+ - Use --cert to specify custom CA certificates for corporate environments
119+ - Use --no-verify-ssl to disable SSL verification (not recommended)
120+ - Use --proxy to configure proxy settings (e.g., --proxy http://proxy:8080)
121+ - Set HTTP_PROXY/HTTPS_PROXY environment variables for proxy configuration
95122 """
96123 # Check if client credentials are provided for unattended authentication
97124 if client_id and client_secret :
@@ -102,8 +129,9 @@ def auth(
102129 return
103130
104131 with console .spinner ("Authenticating with client credentials ..." ):
105- # Create service instance
106- credentials_service = ClientCredentialsService (domain )
132+ credentials_service = ClientCredentialsService (
133+ domain , verify_ssl = not no_verify_ssl , cert = cert , proxy = proxy
134+ )
107135
108136 # If base_url is provided, extract domain from it to override the CLI domain parameter
109137 if base_url :
@@ -127,56 +155,59 @@ def auth(
127155
128156 # Interactive authentication flow (existing logic)
129157 with console .spinner ("Authenticating with UiPath ..." ):
130- portal_service = PortalService (domain )
131-
132- if not force :
133- if (
134- os .getenv ("UIPATH_URL" )
135- and os .getenv ("UIPATH_TENANT_ID" )
136- and os .getenv ("UIPATH_ORGANIZATION_ID" )
137- ):
158+ with PortalService (
159+ domain , verify_ssl = not no_verify_ssl , cert = cert , proxy = proxy
160+ ) as portal_service :
161+ if not force :
162+ if (
163+ os .getenv ("UIPATH_URL" )
164+ and os .getenv ("UIPATH_TENANT_ID" )
165+ and os .getenv ("UIPATH_ORGANIZATION_ID" )
166+ ):
167+ try :
168+ portal_service .ensure_valid_token ()
169+ console .success (
170+ "Authentication successful." ,
171+ )
172+ return
173+ except Exception :
174+ console .info (
175+ "Authentication token is invalid. Please reauthenticate." ,
176+ )
177+
178+ auth_url , code_verifier , state = get_auth_url (domain )
179+
180+ webbrowser .open (auth_url , 1 )
181+ auth_config = get_auth_config ()
182+
183+ console .link (
184+ "If a browser window did not open, please open the following URL in your browser:" ,
185+ auth_url ,
186+ )
187+
188+ server = HTTPServer (port = auth_config ["port" ])
189+ token_data = server .start (state , code_verifier , domain )
190+
191+ if token_data :
192+ portal_service .update_token_data (token_data )
193+ update_auth_file (token_data )
194+ access_token = token_data ["access_token" ]
195+ update_env_file ({"UIPATH_ACCESS_TOKEN" : access_token })
196+
197+ tenants_and_organizations = (
198+ portal_service .get_tenants_and_organizations ()
199+ )
200+ base_url = select_tenant (domain , tenants_and_organizations )
138201 try :
139- portal_service .ensure_valid_token ( )
202+ portal_service .post_auth ( base_url )
140203 console .success (
141204 "Authentication successful." ,
142205 )
143- return
144206 except Exception :
145- console .info (
146- "Authentication token is invalid . Please reauthenticate ." ,
207+ console .error (
208+ "Could not prepare the environment . Please try again ." ,
147209 )
148-
149- auth_url , code_verifier , state = get_auth_url (domain )
150-
151- webbrowser .open (auth_url , 1 )
152- auth_config = get_auth_config ()
153-
154- console .link (
155- "If a browser window did not open, please open the following URL in your browser:" ,
156- auth_url ,
157- )
158-
159- server = HTTPServer (port = auth_config ["port" ])
160- token_data = server .start (state , code_verifier , domain )
161-
162- if token_data :
163- portal_service .update_token_data (token_data )
164- update_auth_file (token_data )
165- access_token = token_data ["access_token" ]
166- update_env_file ({"UIPATH_ACCESS_TOKEN" : access_token })
167-
168- tenants_and_organizations = portal_service .get_tenants_and_organizations ()
169- base_url = select_tenant (domain , tenants_and_organizations )
170- try :
171- portal_service .post_auth (base_url )
172- console .success (
173- "Authentication successful." ,
174- )
175- except Exception :
210+ else :
176211 console .error (
177- "Could not prepare the environment . Please try again." ,
212+ "Authentication failed . Please try again." ,
178213 )
179- else :
180- console .error (
181- "Authentication failed. Please try again." ,
182- )
0 commit comments