chrly/cmd/token.go
ErickSkrauch 778bc615aa
The configuration file was deleted in favor of using environment variables.
Token generation functionality remove. Secret token now provided via CHRLY_SECRET env variable.
2018-02-15 23:57:23 +03:00

30 lines
590 B
Go

package cmd
import (
"fmt"
"log"
"elyby/minecraft-skinsystem/auth"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var tokenCmd = &cobra.Command{
Use: "token",
Short: "Creates a new token, which allows to interact with Chrly API",
Run: func(cmd *cobra.Command, args []string) {
jwtAuth := &auth.JwtAuth{Key: []byte(viper.GetString("chrly.secret"))}
token, err := jwtAuth.NewToken(auth.SkinScope)
if err != nil {
log.Fatalf("Unable to create new token. The error is %v\n", err)
}
fmt.Printf("%s\n", token)
},
}
func init() {
RootCmd.AddCommand(tokenCmd)
}