diff --git a/auth.go b/auth.go index 5302ee39..f9ad66e2 100644 --- a/auth.go +++ b/auth.go @@ -16,10 +16,12 @@ package lksdk import ( "context" + "net/http" "github.com/twitchtv/twirp" "github.com/livekit/protocol/auth" + "github.com/livekit/server-sdk-go/v2/signalling" ) @@ -61,5 +63,20 @@ func (b authBase) withAuth(ctx context.Context, opt authOption, options ...authO return nil, err } - return twirp.WithHTTPRequestHeaders(ctx, signalling.NewHTTPHeaderWithToken(token)) + h := signalling.NewHTTPHeaderWithToken(token) + ctxH, _ := twirp.HTTPRequestHeaders(ctx) + if ctxH != nil { + ctxH = ctxH.Clone() + } else { + ctxH = make(http.Header) + } + + // merge new header with the ones already present in the context + for k, vv := range h { + for _, v := range vv { + ctxH.Add(k, v) + } + } + + return twirp.WithHTTPRequestHeaders(ctx, ctxH) }