Skip to content

riza-io/grpc-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages