diff --git a/cmd/root.go b/cmd/root.go index dd2011f..b6540d8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -4,7 +4,9 @@ import ( "context" "fmt" "os" + "os/exec" "path/filepath" + "strings" "gospt/internal/auth" "gospt/internal/config" @@ -84,4 +86,12 @@ func initConfig() { if err := loader.Load(); err != nil { panic(err) } + if config.Values.ClientSecretCmd != "" { + args := strings.Fields(config.Values.ClientSecretCmd) + secret, err := exec.Command(args[0], args[1:]...).Output() + if err != nil { + panic(err) + } + config.Values.ClientSecret = strings.TrimSpace(string(secret)) + } } diff --git a/internal/config/config.go b/internal/config/config.go index aebac1d..8a47056 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,6 +1,7 @@ package config var Values struct { - ClientId string `yaml:"client_id"` - ClientSecret string `yaml:"client_secret"` + ClientId string `yaml:"client_id"` + ClientSecret string `yaml:"client_secret"` + ClientSecretCmd string `yaml:"client_secret_cmd"` }