Chromium Code Reviews| Index: client/cmd/logdog_butler/main.go |
| diff --git a/client/cmd/logdog_butler/main.go b/client/cmd/logdog_butler/main.go |
| index e4a39c7e8fbba611650282d743a7ca3cec08f7fb..7849032429d181e28bfb94ae4d34e7450777e4b8 100644 |
| --- a/client/cmd/logdog_butler/main.go |
| +++ b/client/cmd/logdog_butler/main.go |
| @@ -29,6 +29,7 @@ import ( |
| "github.com/luci/luci-go/common/paniccatcher" |
| "github.com/maruel/subcommands" |
| "golang.org/x/net/context" |
| + "golang.org/x/oauth2" |
| ) |
| const ( |
| @@ -117,15 +118,23 @@ func (a *application) addFlags(fs *flag.FlagSet) { |
| "of wire-format efficiency.") |
| } |
| +func (a *application) authenticator(ctx context.Context) (*auth.Authenticator, error) { |
| + opts, err := a.authFlags.Options() |
| + if err != nil { |
| + return nil, err |
| + } |
| + opts.Context = ctx |
| + return auth.NewAuthenticator(auth.SilentLogin, opts), nil |
| +} |
| + |
| func (a *application) authenticatedClient(ctx context.Context) (*http.Client, error) { |
| if a.client == nil { |
| - opts, err := a.authFlags.Options() |
| + authenticator, err := a.authenticator(ctx) |
| if err != nil { |
| return nil, err |
| } |
| - opts.Context = ctx |
| - client, err := auth.NewAuthenticator(auth.SilentLogin, opts).Client() |
| + client, err := authenticator.Client() |
| if err != nil { |
| return nil, err |
| } |
| @@ -134,6 +143,14 @@ func (a *application) authenticatedClient(ctx context.Context) (*http.Client, er |
| return a.client, nil |
| } |
| +func (a *application) authenticatedTokenSource(ctx context.Context) (oauth2.TokenSource, error) { |
|
Vadim Sh.
2016/03/29 19:02:37
nit: just tokenSource(). It can't be "unauthentica
dnj
2016/03/29 19:27:20
Done.
|
| + authenticator, err := a.authenticator(ctx) |
| + if err != nil { |
| + return nil, err |
| + } |
| + return authenticator.TokenSource(), nil |
| +} |
| + |
| func (a *application) configOutput() (output.Output, error) { |
| factory := a.outputConfig.getFactory() |
| if factory == nil { |