From 00f3300bcffd48e55a00b2dcbadd1a9e54bd1990 Mon Sep 17 00:00:00 2001 From: rektdeckard Date: Thu, 8 Aug 2024 00:35:57 -0600 Subject: [PATCH] chore(auth): auto-open browser window for auth --- cmd/lk/cloud.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/lk/cloud.go b/cmd/lk/cloud.go index cdc7fc75..097350b8 100644 --- a/cmd/lk/cloud.go +++ b/cmd/lk/cloud.go @@ -28,6 +28,7 @@ import ( "github.com/urfave/cli/v3" "github.com/livekit/livekit-cli/pkg/config" + "github.com/pkg/browser" ) const ( @@ -237,6 +238,11 @@ 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(). @@ -244,9 +250,11 @@ func tryAuthIfNeeded(ctx context.Context, cmd *cli.Command) error { Action(func() { key, pollErr = pollClaim(ctx, cmd) }). + Context(ctx). Run(); err != nil { return err } + if pollErr != nil { return pollErr }