Skip to content

Conversation

@marrobi
Copy link
Member

@marrobi marrobi commented Feb 5, 2026

Fixes #4856

This PR adds an interactive browser login method to the TRE CLI for easier authentication.

Changes

  • Add InteractiveApiClient class to support browser-based MSAL authentication with token caching
  • Add tre login interactive command that auto-discovers TRE URL from:
    • Previously saved config (~/.config/tre/environment.json)
    • TRE deployment outputs (core/tre_output.json)
  • Update CLI documentation

Usage

# For devcontainer users with a deployed TRE
tre login interactive

# To specify a different TRE instance
tre login interactive --base-url https://mytre.westeurope.cloudapp.azure.com/

@marrobi marrobi requested a review from a team as a code owner February 5, 2026 17:35
Copilot AI review requested due to automatic review settings February 5, 2026 17:35
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Unit Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 0d5f17a.

♻️ This comment has been updated with latest results.

Copy link
Contributor

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 adds an interactive browser-based authentication method to the TRE CLI, addressing scenarios where device code flow is blocked by organizational policies. The implementation follows the existing patterns established by the device-code and client-credentials login methods, with the addition of automatic TRE URL discovery from saved configuration or deployment outputs.

Changes:

  • Added InteractiveApiClient class that uses MSAL's interactive browser authentication with silent token refresh from cache
  • Added tre login interactive command with auto-discovery of TRE URL from ~/.config/tre/environment.json or core/tre_output.json
  • Updated CLI documentation to include the new interactive login method as the recommended approach for developers

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
docs/tre-developers/CLI.md Documents the new interactive browser flow login method with usage examples and auto-discovery behavior
cli/tre/commands/login.py Implements the login_interactive command with base URL auto-discovery and token caching
cli/tre/api_client.py Adds InteractiveApiClient class with support for silent token refresh and interactive browser authentication
CHANGELOG.md Records the enhancement with proper issue reference
Comments suppressed due to low confidence (1)

cli/tre/api_client.py:131

    def get_auth_token() -> str:

@marrobi marrobi requested a review from JC-wk February 5, 2026 19:16
Copy link
Collaborator

@JC-wk JC-wk left a comment

Choose a reason for hiding this comment

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

LGTM

@marrobi
Copy link
Member Author

marrobi commented Feb 9, 2026

/test

Checking CI hasn't been broken.

@marrobi marrobi enabled auto-merge (squash) February 9, 2026 14:56
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🤖 pr-bot 🤖

🏃 Running tests: https://github.com/microsoft/AzureTRE/actions/runs/21829999074 (with refid 755ff696)

(in response to this comment from @marrobi)

@marrobi marrobi merged commit 4f21617 into microsoft:main Feb 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot log in to TRE CLI as policy blocks device code usage

3 participants