Add an Output io.Writer so auth flow output can be redirected - #102
Merged
Merged
Conversation
Ports the equivalent changes from pingfederate-go-client#92. Adds an Output io.Writer field to the authorization-code and device-code configs so consumers can route (or silence, via io.Discard) progress messages, instead of having that output locked to stdout. The default handlers for both flows now stay silent by default and write their progress messages to the configured writer: - Replace OnOpenBrowser / OnDisplayPrompt with Output io.Writer on AuthorizationCode and DeviceCode - Add WithAuthorizationCodeOutput / WithDeviceCodeOutput builder methods - Add DefaultAuthorizationCodeBrowserHandlerTo / DefaultDeviceCodePromptHandlerTo, returning handlers with the same browser-opening behavior that write to a given writer (nil -> silent) - Document the new field in the README "Output control" section
henryrecker-pingidentity
approved these changes
Sep 11, 2026
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
Adds an
Output io.Writerfield to the authorization-code and device-code configs so consumers can route (or silence, viaio.Discard) the progress messages the default handlers write, instead of having that output locked to stdout.This ports the equivalent changes from pingidentity/pingfederate-go-client#92.
Changes
config/pingone.go: newOutputfield on the authorization-code and device-code configs, replacingOnOpenBrowser/OnDisplayPrompt; newWithAuthorizationCodeOutput(w)/WithDeviceCodeOutput(w)builder methodsconfig/authorization_code.go: handler selection uses the default handler honoringOutput; newDefaultAuthorizationCodeBrowserHandlerTo(w)constructor and best-effort write helpersconfig/device_auth.go: same pattern withDefaultDeviceCodePromptHandlerTo(w)config/hooks_test.go(new): coverage for redirecting output,os.Stdout, and silent-by-default behaviorconfig/authorization_code_test.go,config/device_auth_test.go,config/pingone_test.go: coverage for output redirection andio.DiscardREADME.md: document the new fieldBreaking change
Consumers setting
OnOpenBrowserorOnDisplayPromptmust migrate to theOutputfield (or call the*Toconstructors directly), as the default handler is now always used.Testing
go test ./...go vet ./...🤖 Generated with Claude Code