Skip to content

feat: add client credentials unattended auth flow#404

Merged
cristipufu merged 1 commit intomainfrom
feat/client_credentials_auth_flow
Jul 1, 2025
Merged

feat: add client credentials unattended auth flow#404
cristipufu merged 1 commit intomainfrom
feat/client_credentials_auth_flow

Conversation

@cristipufu
Copy link
Copy Markdown
Member

@cristipufu cristipufu commented Jun 13, 2025

Pull Request Overview

This PR adds a client credentials unattended authentication flow to the CLI tool.

  • Introduces new CLI options (--client-id, --client-secret, --base-url) to facilitate unattended authentication.
  • Implements a new authentication branch in auth() to handle client credentials and falls back to interactive mode when credentials are not provided.
  • Adds a new module (src/uipath/_cli/_auth/_client_credentials.py) that encapsulates the client credentials authentication logic.

Usage Example

The external app needs the OR.Execution Orchestrator scope for package publishing.

uipath auth --client-id='12345678-c4c5-4f1f-93ff-4f5ab47d57ea' --client-secret='xxx' --base-url='https://alpha.uipath.com/account/tenant'

uipath publish --tenant

Ref: #388
Ref: UiPath/uipath-langchain-python#96

Development Package

  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath==2.0.72.dev1004040499",

  # Any version from PR
  "uipath>=2.0.72.dev1004040000,<2.0.72.dev1004050000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath = { index = "testpypi" }

This comment was marked as outdated.

@cristipufu cristipufu added the build:dev Create a dev build from the pr label Jun 13, 2025
@cristipufu cristipufu force-pushed the feat/client_credentials_auth_flow branch 3 times, most recently from 3c36ebf to 13a0d10 Compare June 13, 2025 17:33
Comment thread src/uipath/_cli/_auth/_client_credentials.py Outdated
Comment thread src/uipath/_cli/_auth/_client_credentials.py
@cristipufu cristipufu force-pushed the feat/client_credentials_auth_flow branch 2 times, most recently from 151ed0b to f710149 Compare July 1, 2025 10:40
Comment thread src/uipath/_cli/_auth/_client_credentials.py Fixed
Comment thread src/uipath/_cli/_auth/_client_credentials.py Fixed
Comment thread src/uipath/_cli/_auth/_client_credentials.py Fixed
@cristipufu cristipufu force-pushed the feat/client_credentials_auth_flow branch from f710149 to ef9e00d Compare July 1, 2025 10:44
@cristipufu cristipufu merged commit 391c058 into main Jul 1, 2025
16 checks passed
@cristipufu cristipufu deleted the feat/client_credentials_auth_flow branch July 1, 2025 10:46
@cristipufu cristipufu requested a review from Copilot July 1, 2025 10:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an unattended client credentials authentication flow to the CLI, allowing non-interactive login using a client ID, client secret, and base URL.

  • Adds --client-id, --client-secret, and --base-url CLI options and branches auth() to handle client credentials.
  • Implements ClientCredentialsService to acquire tokens and update environment variables.
  • Falls back to existing interactive flow when credentials aren’t provided.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/uipath/_cli/cli_auth.py Adds new options and branching logic for client creds.
src/uipath/_cli/_auth/_client_credentials.py New service module for implementing client creds flow.
Comments suppressed due to low confidence (2)

src/uipath/_cli/_auth/_client_credentials.py:71

  • The new client credentials authentication flow isn’t covered by existing tests. Add unit tests for authenticate() (including success, 400, 401, and network failure scenarios) to ensure reliability.
    def authenticate(

src/uipath/_cli/cli_auth.py:101

  • The name console is not imported in this file, which will cause a NameError. Please import the appropriate console/logger instance (e.g. from ._utils._console import console).
            )

Comment on lines +109 to +113
if base_url:
extracted_domain = credentials_service.extract_domain_from_base_url(
base_url
)
credentials_service.domain = extracted_domain
Copy link

Copilot AI Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This inner if base_url: check is redundant because base_url was already validated above. You can remove this condition to simplify the logic.

Suggested change
if base_url:
extracted_domain = credentials_service.extract_domain_from_base_url(
base_url
)
credentials_service.domain = extracted_domain
extracted_domain = credentials_service.extract_domain_from_base_url(
base_url
)
credentials_service.domain = extracted_domain

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:dev Create a dev build from the pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants