fix: prefer interactive browser auth over device code in scripts/auth.py#45
Closed
suyask-msft wants to merge 1 commit into
Closed
fix: prefer interactive browser auth over device code in scripts/auth.py#45suyask-msft wants to merge 1 commit into
suyask-msft wants to merge 1 commit into
Conversation
Default auth flow for local development now opens a browser once and completes silently, rather than prompting the user to copy a device code into the browser on every new process. The previous DeviceCodeCredential flow led to 3+ code-copy cycles during a single setup in real session logs, even though the target machines had browsers available. Changes to scripts/auth.py: - New priority order: service principal -> InteractiveBrowserCredential -> DeviceCodeCredential (opt-in fallback) - Added DATAVERSE_AUTH_DEVICE_CODE=1 env var as explicit opt-in for device-code flow (for headless/CI/SSH environments with no browser) - Both interactive credentials share the same TokenCachePersistenceOptions and AuthenticationRecord, so token caching behavior is unchanged - If browser auth fails, error messages now suggest the device-code fallback - get_token() now handles both InteractiveBrowserCredential and DeviceCodeCredential for first-login AuthenticationRecord persistence Version bump: 1.2.0 -> 1.2.1 (PATCH -- script-level fix, no skill behavior change, no breaking change for users who already had DATAVERSE_AUTH_DEVICE_CODE or a working token cache). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Collaborator
Author
|
Closing in favor of a more focused fix. The core friction observed in real-world testing turned out to be cross-tenant AuthenticationRecord invalidation (user re-authing every time they switched tenants), not the DeviceCodeCredential vs InteractiveBrowserCredential choice. The smaller, lower-risk fix (per-tenant AuthenticationRecord keying) will land as a separate PR. The broader 'switch credential type' question deserves multi-environment testing before shipping — parking for now. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Default auth flow for local development now opens a browser once and completes silently, rather than prompting the user to copy a device code into the browser on every new process. The previous
DeviceCodeCredentialflow led to multiple code-copy cycles during a single setup in real-world testing, even on machines that had browsers available.Changes
Priority order in
scripts/auth.pyBefore:
CLIENT_ID+CLIENT_SECRET)DeviceCodeCredential(always)After:
InteractiveBrowserCredential— default for local dev, opens browser onceDeviceCodeCredential— explicit opt-in viaDATAVERSE_AUTH_DEVICE_CODE=1for headless/CI/SSHNew env var
DATAVERSE_AUTH_DEVICE_CODE=1— set in the environment (or.env) to force device-code flow. Intended for scenarios where no browser is available.Error handling
If interactive browser auth fails (e.g., no browser), the error message now explicitly points to
DATAVERSE_AUTH_DEVICE_CODE=1as the fallback.Token caching unchanged
Both interactive credentials share the same
TokenCachePersistenceOptions(OS credential store) andAuthenticationRecordpersistence, so:Evidence
During real-world testing, users on Windows development machines saw multiple device-code prompts across several
auth.pyinvocations in a single setup, despite having a working browser. Each prompt required manually copying the code and completing a browser sign-in.Version bump
1.2.0 → 1.2.1 (PATCH — script-level fix, no skill behavior change, no breaking change for users who already have
DATAVERSE_AUTH_DEVICE_CODE=1or a working token cache)Test plan
ast.parse) — passespython .github/evals/static_checks.py— passespython .github/evals/version_bump_check.py— passesdv-connectflow opens a browser once, no code-copy promptsDATAVERSE_AUTH_DEVICE_CODE=1forces device code flowInteractiveBrowserCredentialis reused by subsequent processes