diff --git a/cmd/auth.go b/cmd/auth.go index 41fe295..dfd8470 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -4,6 +4,7 @@ package cmd import ( + "fmt" "log/slog" "os" @@ -22,6 +23,7 @@ const ( var ( credential string cacheToken string + authPort int ) var authCmd = &cobra.Command{ @@ -29,9 +31,11 @@ var authCmd = &cobra.Command{ Short: authShort, Long: authLong, Run: func(cmd *cobra.Command, args []string) { + redirectURL := fmt.Sprintf("http://localhost:%d", authPort) if _, err := auth.NewY2BService( auth.WithCredential(credential, pkg.Root.FS()), auth.WithCacheToken(cacheToken, pkg.Root.FS()), + auth.WithRedirectURL(redirectURL), ).GetService(); err != nil { slog.Error("authentication failed", "error", err) os.Exit(1) @@ -48,4 +52,7 @@ func init() { authCmd.Flags().StringVarP( &cacheToken, "cacheToken", "t", "youtube.token.json", cacheUsage, ) + authCmd.Flags().IntVarP( + &authPort, "port", "p", 8216, "Port for OAuth redirect URL", + ) }