Skip to content

Commit 13677b5

Browse files
author
Joe Doss
committed
Add STEP_OPEN_BROWSER env var to skip opening a browser and just output the authURL.
1 parent cee7040 commit 13677b5

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

command/oauth/cmd.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -784,18 +784,24 @@ func (o *oauth) DoLoopbackAuthorization() (*token, error) {
784784
return nil, err
785785
}
786786

787-
if err := exec.OpenInBrowser(authURL, o.browser); err != nil {
788-
fmt.Fprintln(os.Stderr, "Cannot open a web browser on your platform.")
789-
fmt.Fprintln(os.Stderr)
790-
fmt.Fprintln(os.Stderr, "Open a local web browser and visit:")
791-
fmt.Fprintln(os.Stderr)
792-
fmt.Fprintln(os.Stderr, authURL)
793-
fmt.Fprintln(os.Stderr)
787+
skipBrowser := os.Getenv("STEP_OPEN_BROWSER") == "false"
788+
789+
if !skipBrowser {
790+
if err := exec.OpenInBrowser(authURL, o.browser); err != nil {
791+
fmt.Fprintln(os.Stderr, "Cannot open a web browser on your platform.")
792+
fmt.Fprintln(os.Stderr)
793+
fmt.Fprintln(os.Stderr, "Open a local web browser and visit:")
794+
fmt.Fprintln(os.Stderr)
795+
fmt.Fprintln(os.Stderr, authURL)
796+
fmt.Fprintln(os.Stderr)
797+
} else {
798+
fmt.Fprintln(os.Stderr, "Your default web browser has been opened to visit:")
799+
fmt.Fprintln(os.Stderr)
800+
fmt.Fprintln(os.Stderr, authURL)
801+
fmt.Fprintln(os.Stderr)
802+
}
794803
} else {
795-
fmt.Fprintln(os.Stderr, "Your default web browser has been opened to visit:")
796-
fmt.Fprintln(os.Stderr)
797-
fmt.Fprintln(os.Stderr, authURL)
798-
fmt.Fprintln(os.Stderr)
804+
fmt.Fprintln(os.Stderr, authURL)
799805
}
800806

801807
// Wait for response and return the token

0 commit comments

Comments
 (0)