Skip to content

Commit

Permalink
fix opening browser on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hickford committed Jun 15, 2024
1 parent abcaa71 commit 5b749cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,20 @@ func getToken(ctx context.Context, c oauth2.Config, authURLSuffix string) (*oaut
authCodeURL += authURLSuffix
fmt.Fprintf(os.Stderr, "Please complete authentication in your browser...\n%s\n", authCodeURL)
var open string
var p []string
switch runtime.GOOS {
case "windows":
open = "start"
open = "rundll32"
p = append(p, "url.dll,FileProtocolHandler")
case "darwin":
open = "open"
default:
open = "xdg-open"
}
p = append(p, authCodeURL)
// TODO: wait for server to start before opening browser
if _, err := exec.LookPath(open); err == nil {
err = exec.Command(open, authCodeURL).Run()
err = exec.Command(open, p...).Run()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5b749cb

Please sign in to comment.