feat: support to disable auto open browser#365
Conversation
a95722e to
123f8af
Compare
Bububuger
left a comment
There was a problem hiding this comment.
LGTM — clean fix wiring the existing --no-browser flag into device flow logic.
|
@PeterGuy326 Could you help review this PR? Thanks a lot! |
|
Thanks for the fix! The wiring into the device flow is correct: One thing to address before merge, though. The flag is now public, but only works for one of three login paths
This PR also un-hides the flag (removes Note Suggested change1. Wire // internal/auth/oauth_provider.go
if !p.NoBrowser {
if err := openBrowser(authURL); err != nil && p.logger != nil {
p.logger.Warn(i18n.T("无法自动打开浏览器"), "error", err)
}
}And in provider := authpkg.NewOAuthProvider(configDir, nil)
provider.Output = cmd.ErrOrStderr()
provider.NoBrowser, _ = cmd.Flags().GetBool("no-browser")2. (consistency, optional) 3. Add a test. The PAT path already has an
Verification — please attach a screenshotAfter the change, please paste a screenshot (or terminal capture) showing each case so we can confirm the loop is closed:
Plus |
|
Thanks for the fix — verified locally that the device flow path now works: One gap before merge: Repro: The OAuth flow already prints the manual URL ("如果浏览器未自动打开,请手动访问: "), so suppressing the auto-open is safe — the user just opens that link. Suggested follow-up (3 small changes), mirroring what you did for the device flow:
type OAuthProvider struct {
// ...
NoBrowser bool
}
if !p.NoBrowser {
if err := openBrowser(authURL); err != nil && p.logger != nil {
p.logger.Warn(i18n.T("无法自动打开浏览器"), "error", err)
}
}
provider := authpkg.NewOAuthProvider(configDir, nil)
provider.Output = cmd.ErrOrStderr()
provider.NoBrowser, _ = cmd.Flags().GetBool("no-browser")
configureOAuthProviderCompatibility(provider, configDir)With that, |
Problem
dingtalk-workspace-cli/internal/app/auth_command.go
Line 182 in 5ce7cb6
The --no-browser flag was already defined on dws auth login but never wired to the device flow logic — the browser always opened regardless.
Fix