Skip to content

Commit 74af5a6

Browse files
authored
Merge pull request #1595 from smallstep/herman/oauth-device-authorization-skip-code
2 parents d288552 + 99d8a58 commit 74af5a6

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

command/oauth/cmd.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,12 @@ func (o *oauth) DoDeviceAuthorization() (*token, error) {
891891
return nil, errors.Wrap(err, "failure decoding device authz response to JSON")
892892
}
893893

894+
shouldPrintCode := true
894895
switch {
895896
case idr.VerificationURIComplete != "":
896897
// Prefer VerificationURIComplete if present for user convenience
897898
idr.VerificationURI = idr.VerificationURIComplete
899+
shouldPrintCode = false
898900
case idr.VerificationURI != "":
899901
// do nothing
900902
case idr.VerificationURL != "":
@@ -909,8 +911,12 @@ func (o *oauth) DoDeviceAuthorization() (*token, error) {
909911
idr.Interval = defaultDeviceAuthzInterval
910912
}
911913

912-
fmt.Fprintf(os.Stderr, "Visit %s and enter the code:\n", idr.VerificationURI)
913-
fmt.Fprintln(os.Stderr, idr.UserCode)
914+
if shouldPrintCode {
915+
fmt.Fprintf(os.Stderr, "Visit %s and enter the code:\n", idr.VerificationURI)
916+
fmt.Fprintln(os.Stderr, idr.UserCode)
917+
} else {
918+
fmt.Fprintf(os.Stderr, "Visit %s:\n", idr.VerificationURI)
919+
}
914920

915921
// Poll the Token endpoint until the user completes the flow.
916922
data = url.Values{}

0 commit comments

Comments
 (0)