-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
cmd_web_token.go
55 lines (47 loc) · 1.23 KB
/
cmd_web_token.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package client
import (
"errors"
"golang.org/x/net/context"
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
)
type cmdWebAuthToken struct {
libkb.Contextified
}
func newCmdWebAuthToken(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "web-auth-token",
Description: "Generate a Web auth token for the current user",
Action: func(c *cli.Context) {
cl.ChooseCommand(&cmdWebAuthToken{Contextified: libkb.NewContextified(g)}, "web-auth-token", c)
},
}
}
func (c *cmdWebAuthToken) Run() error {
configClient, err := GetConfigClient(c.G())
if err != nil {
return err
}
tok, err := configClient.GenerateWebAuthToken(context.Background())
if err != nil {
return err
}
dui := c.G().UI.GetDumbOutputUI()
_, _ = dui.Printf("%s\n", tok)
return nil
}
func (c *cmdWebAuthToken) ParseArgv(ctx *cli.Context) error {
if len(ctx.Args()) != 0 {
return errors.New("no arguments allowed")
}
return nil
}
func (c *cmdWebAuthToken) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
}
}