From 4f5a19bf3007aba3718f2b0c2d83708e3b62ca13 Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 10 Mar 2020 16:47:01 +0000 Subject: [PATCH] Fix Auth Headers (#1324) Co-authored-by: Ben Toogood --- grpc.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/grpc.go b/grpc.go index e1043af..c090065 100644 --- a/grpc.go +++ b/grpc.go @@ -123,7 +123,7 @@ func (g *grpcClient) call(ctx context.Context, node *registry.Node, req client.R if md, ok := metadata.FromContext(ctx); ok { header = make(map[string]string, len(md)) for k, v := range md { - header[k] = v + header[strings.ToLower(k)] = v } } else { header = make(map[string]string) @@ -133,9 +133,12 @@ func (g *grpcClient) call(ctx context.Context, node *registry.Node, req client.R header["timeout"] = fmt.Sprintf("%d", opts.RequestTimeout) // set the content type for the request header["x-content-type"] = req.ContentType() + // set the authorization token if one is saved locally - if token, err := config.Get("token"); err == nil && len(token) > 0 { - header["authorization"] = BearerScheme + token + if len(header["authorization"]) == 0 { + if token, err := config.Get("token"); err == nil && len(token) > 0 { + header["authorization"] = BearerScheme + token + } } md := gmetadata.New(header)