Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions command/oauth/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,12 @@ func (o *oauth) DoDeviceAuthorization() (*token, error) {
return nil, errors.Wrap(err, "failure decoding device authz response to JSON")
}

shouldPrintCode := true
switch {
case idr.VerificationURIComplete != "":
// Prefer VerificationURIComplete if present for user convenience
idr.VerificationURI = idr.VerificationURIComplete
shouldPrintCode = false
case idr.VerificationURI != "":
// do nothing
case idr.VerificationURL != "":
Expand All @@ -909,8 +911,12 @@ func (o *oauth) DoDeviceAuthorization() (*token, error) {
idr.Interval = defaultDeviceAuthzInterval
}

fmt.Fprintf(os.Stderr, "Visit %s and enter the code:\n", idr.VerificationURI)
fmt.Fprintln(os.Stderr, idr.UserCode)
if shouldPrintCode {
fmt.Fprintf(os.Stderr, "Visit %s and enter the code:\n", idr.VerificationURI)
fmt.Fprintln(os.Stderr, idr.UserCode)
} else {
fmt.Fprintf(os.Stderr, "Visit %s:\n", idr.VerificationURI)
}

// Poll the Token endpoint until the user completes the flow.
data = url.Values{}
Expand Down
Loading