refactor bearer token on the client side

This commit is contained in:
David Zhao
2021-01-18 13:27:01 -08:00
parent 513b40c4ce
commit 834a4747ac
6 changed files with 115 additions and 40 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"github.com/twitchtv/twirp"
"github.com/urfave/cli/v2"
"github.com/livekit/livekit-server/cmd/cli/client"
"github.com/livekit/livekit-server/pkg/auth"
"github.com/livekit/livekit-server/pkg/logger"
"github.com/livekit/livekit-server/proto/livekit"
@@ -109,7 +110,7 @@ func contextWithAccessToken(c *cli.Context, grant *auth.VideoGrant) context.Cont
}
if token != "" {
header := make(http.Header)
header.Set("Authorization", "Bearer "+token)
client.SetAuthorizationToken(header, token)
if tctx, err := twirp.WithHTTPRequestHeaders(ctx, header); err == nil {
logger.Debugw("requesting with token")
ctx = tctx