Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultApiTokenHeaderName = "api_token"
DefaultApiTokenHeaderName used if apiTokenHeaderName is empty string
Variables ¶
This section is empty.
Functions ¶
func ClientTokenAuth ¶
func ClientTokenAuth(apiToken string, apiTokenHeaderName string) grpc.UnaryClientInterceptor
ClientTokenAuth provides token header for authentication
Example ¶
Example client with token auth
conn, err := grpc.Dial( "localhost:50002", grpc.WithBlock(), grpc.WithInsecure(), grpc.WithUnaryInterceptor(ClientTokenAuth( "secret_token", "<header name or empty for default>", )), ) if err != nil { log.Fatalf("dial failed: %s", err.Error()) } defer conn.Close() // ...
Output:
func ServerTokenAuth ¶
func ServerTokenAuth(apiToken string, apiTokenHeaderName string) grpc.UnaryServerInterceptor
ServerTokenAuth provides token header for authentication
Example ¶
Example server with token auth
grpcServer := grpc.NewServer( grpc.ChainUnaryInterceptor( ServerTokenAuth( "secret_token", "<header name or empty for default>", ), ), ) fmt.Println(grpcServer)
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.