grpc-go

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2023 License: MIT

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)

Directories

Path Synopsis
credentials

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL