Skip to content

Commit

Permalink
chore(auth): auto-open browser window for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
rektdeckard committed Aug 10, 2024
1 parent 949d495 commit 00f3300
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/lk/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/urfave/cli/v3"

"github.com/livekit/livekit-cli/pkg/config"
"github.com/pkg/browser"
)

const (
Expand Down Expand Up @@ -237,16 +238,23 @@ func tryAuthIfNeeded(ctx context.Context, cmd *cli.Command) error {

// poll for keys
fmt.Printf("Please confirm access by visiting:\n\n %s\n\n", authURL.String())

if err := browser.OpenURL(authURL.String()); err != nil {
return err
}

var key *config.AccessKey
var pollErr error
if err := spinner.New().
Title("Awaiting confirmation...").
Action(func() {
key, pollErr = pollClaim(ctx, cmd)
}).
Context(ctx).
Run(); err != nil {
return err
}

if pollErr != nil {
return pollErr
}
Expand Down

0 comments on commit 00f3300

Please sign in to comment.