-
Notifications
You must be signed in to change notification settings - Fork 5
/
dial_opts_test.go
49 lines (41 loc) · 958 Bytes
/
dial_opts_test.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
package grpcutil_test
import (
"log"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/authzed/grpcutil"
)
func ExampleWithSystemCerts() {
withSysCerts, err := grpcutil.WithSystemCerts(grpcutil.VerifyCA)
if err != nil {
log.Fatal(err)
}
_, err = grpc.Dial("grpc.authzed.com:443", withSysCerts)
if err != nil {
log.Fatal(err)
}
}
func ExampleWithBearerToken() {
withSystemCerts, err := grpcutil.WithSystemCerts(grpcutil.VerifyCA)
if err != nil {
log.Fatal(err)
}
_, err = grpc.Dial(
"grpc.authzed.com:443",
withSystemCerts,
grpcutil.WithBearerToken("t_your_token_here_1234567deadbeef"),
)
if err != nil {
log.Fatal(err)
}
}
func ExampleWithInsecureBearerToken() {
_, err := grpc.Dial(
"grpc.authzed.com:443",
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpcutil.WithInsecureBearerToken("t_your_token_here_1234567deadbeef"),
)
if err != nil {
log.Fatal(err)
}
}