Categorygithub.com/riza-io/grpc-go
repository
0.2.0
Repository: https://github.com/riza-io/grpc-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Shared libraries and tools for Go gRPC services

Usage: go get github.com/riza-io/go-grpc

Credentials

Bearer tokens

In your client:

opts := []grpc.DialOption{
    grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
    grpc.WithPerRPCCredentials(bearer.NewPerRPCCredentials("your bearer token")),
}

conn, err := grpc.Dial(hostname+":443", opts...)

Get a token from within your service handler:

token, err := bearer.TokenFromContext(ctx)
HTTP basic authentication (user-id and password)

In your client:

opts := []grpc.DialOption{
    grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
    grpc.WithPerRPCCredentials(basic.NewPerRPCCredentials("your user-id", "your password")),
}

conn, err := grpc.Dial(hostname+":443", opts...)

Get basic auth credentials from within your service handler:

creds, err := basic.CredentialsFromContext(ctx)