Skip to content

chore/change auth clientid #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.0.2.dev2"
version = "2.0.3"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
Expand Down
41 changes: 35 additions & 6 deletions src/uipath/_cli/_auth/_auth_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ def do_OPTIONS(self):

class HTTPSServer:
def __init__(self, port=6234, cert_file="localhost.crt", key_file="localhost.key"):
"""Initialize HTTPS server with configurable parameters."""
"""Initialize HTTPS server with configurable parameters.

Args:
port (int, optional): Port number to run the server on. Defaults to 6234.
cert_file (str, optional): SSL certificate file. Defaults to "localhost.crt".
key_file (str, optional): SSL key file. Defaults to "localhost.key".
"""
self.current_path = os.path.dirname(os.path.abspath(__file__))
self.port = port
self.cert_file = os.path.join(self.current_path, "localhost.crt")
Expand All @@ -123,17 +129,31 @@ def __init__(self, port=6234, cert_file="localhost.crt", key_file="localhost.key
self.should_shutdown = False

def token_received_callback(self, token_data):
"""Callback for when a token is received."""
"""Callback for when a token is received.

Args:
token_data (dict): The received token data.
"""
self.token_data = token_data
self.should_shutdown = True

def create_server(self, state, code_verifier, domain):
"""Create and configure the HTTPS server."""
"""Create and configure the HTTPS server.

Args:
state (str): The OAuth state parameter.
code_verifier (str): The PKCE code verifier.
domain (str): The domain for authentication.

Returns:
socketserver.TCPServer: The configured HTTPS server.
"""
# Create SSL context
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(self.cert_file, self.key_file)

# Create server
# Create server with address reuse
socketserver.TCPServer.allow_reuse_address = True
handler = make_request_handler_class(
state, code_verifier, self.token_received_callback, domain
)
Expand All @@ -143,7 +163,16 @@ def create_server(self, state, code_verifier, domain):
return self.httpd

def start(self, state, code_verifier, domain):
"""Start the server."""
"""Start the server.

Args:
state (str): The OAuth state parameter.
code_verifier (str): The PKCE code verifier.
domain (str): The domain for authentication.

Returns:
dict: The received token data or an empty dict if no token was received.
"""
if not self.httpd:
self.create_server(state, code_verifier, domain)

Expand All @@ -159,7 +188,7 @@ def start(self, state, code_verifier, domain):
return self.token_data if self.token_data else {}

def stop(self):
"""Stop the server gracefully."""
"""Stop the server gracefully and cleanup resources."""
if self.httpd:
self.httpd.server_close()
self.httpd = None
Loading