Skip to content

feat: add require-user-name support to AuthConfiguration and Auth0 endpoints#636

Merged
Martin-Molinero merged 4 commits intoQuantConnect:masterfrom
Romazes:fix-auth0-endpoints-payload
Mar 11, 2026
Merged

feat: add require-user-name support to AuthConfiguration and Auth0 endpoints#636
Martin-Molinero merged 4 commits intoQuantConnect:masterfrom
Romazes:fix-auth0-endpoints-payload

Conversation

@Romazes
Copy link
Contributor

@Romazes Romazes commented Mar 10, 2026

Description

  • Adds require-user-name optional flag to AuthConfiguration (mirrors require-project-id pattern)
  • When set, prompts user for their login ID before OAuth (checks CLI args → lean config → interactive prompt)
  • Auth0Client.read includes userId in the POST payload when provided
  • Auth0Client.authorize appends &userId={user_name} to the authorization URL
  • Enables Charles Schwab (and future brokerages) to pass a login ID into the OAuth flow

How Has This Been Tested?

  • 4 new tests covering authorize and read with/without user_name

…dpoints

Adds optional userId parameter to Auth0 read and authorize flows so brokerages
like Charles Schwab can pass a login ID to pre-fill the OAuth authorization page.
AuthConfiguration now reads require-user-name from config JSON, prompts the user
for their login ID (checking CLI args and lean config first), and threads the value
through get_authorization → Auth0Client.read (payload) and Auth0Client.authorize (URL).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Romazes Romazes requested a review from Martin-Molinero March 10, 2026 21:28
@Romazes Romazes self-assigned this Mar 10, 2026
@Romazes Romazes added the bug Something isn't working label Mar 10, 2026
Romazes and others added 2 commits March 11, 2026 00:09
After prompting for login ID, the value is saved to lean_config under the
derived key (e.g. charles-schwab-user-name) so subsequent runs skip the prompt.
Adds 4 unit tests covering all get_user_name code paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Auth

When the Auth0 OAuth flow returns a new account list, the previously
saved account number in lean.json may no longer be valid. Previously the
code would silently use the stale value, causing live trading to be
configured with the wrong account.

Now, after fetching API account IDs:
- If the saved account is no longer in the API response, it is cleared
  so the user is prompted to select a valid one.
- If the API returns multiple accounts (even if the saved value is still
  valid), it is cleared so the user actively confirms their selection
  from the current list.
- If the API returns exactly one account and it matches the saved value,
  no prompt is needed.

Also adds three unit tests covering stale, ambiguous, and valid cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Auth

Use plain brokerage_id as cache key when user_name is None to preserve
original behaviour; use (brokerage_id, user_name) tuple when user_name
is provided so different users get isolated cache entries.
Adds two cache tests: no-user-name single-call check and per-user-name
isolation check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants