Skip to content
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-dev"
version = "0.0.66"
version = "0.0.67"
description = "UiPath Developer Console"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
16 changes: 15 additions & 1 deletion src/uipath/dev/server/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,15 @@ def select_tenant(tenant_name: str) -> dict[str, Any]:
def _finalize_tenant(auth: AuthState, tenant_name: str) -> None:
"""Write .env and os.environ with the resolved credentials."""
org_name = auth.organization.get("name", "")
org_id = auth.organization.get("id", "")
domain = f"https://{auth.environment}.uipath.com"
uipath_url = f"{domain}/{org_name}/{tenant_name}"
access_token = auth.token_data.get("access_token", "")

# Resolve tenant ID from the tenants list
tenant = next((t for t in auth.tenants if t["name"] == tenant_name), None)
tenant_id = tenant["id"] if tenant else ""

auth.uipath_url = uipath_url
auth.status = "authenticated"

Expand All @@ -1007,12 +1012,19 @@ def _finalize_tenant(auth: AuthState, tenant_name: str) -> None:
# Update os.environ
os.environ["UIPATH_ACCESS_TOKEN"] = access_token
os.environ["UIPATH_URL"] = uipath_url
os.environ["UIPATH_TENANT_ID"] = tenant_id
os.environ["UIPATH_ORGANIZATION_ID"] = org_id

# Write/update .env file (preserving comments, blank lines, and ordering)
env_path = Path.cwd() / ".env"
lines: list[str] = []
updated_keys: set[str] = set()
new_values = {"UIPATH_ACCESS_TOKEN": access_token, "UIPATH_URL": uipath_url}
new_values = {
"UIPATH_ACCESS_TOKEN": access_token,
"UIPATH_URL": uipath_url,
"UIPATH_TENANT_ID": tenant_id,
"UIPATH_ORGANIZATION_ID": org_id,
}

if env_path.exists():
with open(env_path) as f:
Expand Down Expand Up @@ -1043,6 +1055,8 @@ def logout() -> None:

os.environ.pop("UIPATH_ACCESS_TOKEN", None)
os.environ.pop("UIPATH_URL", None)
os.environ.pop("UIPATH_TENANT_ID", None)
os.environ.pop("UIPATH_ORGANIZATION_ID", None)

reset_auth_state()

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.