forked from DelineaXPM/tss-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (35 loc) · 846 Bytes
/
main.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
package main
import (
"fmt"
"os"
"github.com/rs/zerolog/log"
"github.com/tsubus/tss-sdk-go/v3/server"
)
func main() {
var userCredential server.UserCredential
accessToken := os.Getenv("TSS_TOKEN")
if accessToken == "" {
userCredential = server.UserCredential{
Username: os.Getenv("TSS_USERNAME"),
Password: os.Getenv("TSS_PASSWORD"),
}
} else {
userCredential = server.UserCredential{
AccessToken: accessToken,
}
}
tss, err := server.New(server.Configuration{
Credentials: userCredential,
Tenant: os.Getenv("TSS_TENANT"),
})
if err != nil {
log.Fatal().Err(err).Msg("error initializing the server configuration")
}
s, err := tss.Secret(1)
if err != nil {
log.Fatal().Err(err).Msg("error calling server.Secret")
}
if pw, ok := s.Field("password"); ok {
fmt.Print("the password is", pw)
}
}