From 56be6b383d697dcce888085d8dbec018cc477c81 Mon Sep 17 00:00:00 2001 From: Natalie Bridgers Date: Thu, 23 Apr 2026 16:19:33 -0500 Subject: [PATCH] api key? interesting but ok --- pkg/config/config.go | 14 ++++++++++++++ pkg/spxrpc/place_stream_game.go | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 5dcb79c0..6356e8b7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -159,6 +159,8 @@ type CLI struct { DisableSyndication bool LegacySegmentation bool GamesAPIURL string + GamesAPIClientKey string + GamesAPIClientSecret string } // ContentFilters represents the content filtering configuration @@ -706,6 +708,18 @@ func (cli *CLI) NewCommand(name string) *urfavecli.Command { Destination: &cli.GamesAPIURL, Sources: urfavecli.EnvVars("SP_GAMES_API_URL"), }, + &urfavecli.StringFlag{ + Name: "games-api-client-key", + Usage: "Client key for authenticating with the games.gamesgamesgamesgames API", + Destination: &cli.GamesAPIClientKey, + Sources: urfavecli.EnvVars("SP_GAMES_API_CLIENT_KEY"), + }, + &urfavecli.StringFlag{ + Name: "games-api-client-secret", + Usage: "Client secret for authenticating with the games.gamesgamesgamesgames API", + Destination: &cli.GamesAPIClientSecret, + Sources: urfavecli.EnvVars("SP_GAMES_API_CLIENT_SECRET"), + }, &urfavecli.BoolFlag{ Name: "livepeer-debug", Usage: "log livepeer segments to $SP_DATA_DIR/livepeer-debug", diff --git a/pkg/spxrpc/place_stream_game.go b/pkg/spxrpc/place_stream_game.go index 82b13e23..f994be1d 100644 --- a/pkg/spxrpc/place_stream_game.go +++ b/pkg/spxrpc/place_stream_game.go @@ -40,6 +40,13 @@ func (s *Server) handlePlaceStreamGameSearch(ctx context.Context, cursor string, return nil, echo.NewHTTPError(http.StatusInternalServerError, "failed to build games request") } + if s.cli.GamesAPIClientKey != "" { + req.Header.Set("X-Client-Key", s.cli.GamesAPIClientKey) + } + if s.cli.GamesAPIClientSecret != "" { + req.Header.Set("X-Client-Secret", s.cli.GamesAPIClientSecret) + } + resp, err := http.DefaultClient.Do(req) if err != nil { return nil, echo.NewHTTPError(http.StatusBadGateway, "games API unreachable") @@ -82,11 +89,17 @@ func (s *Server) handlePlaceStreamGameGetGame(ctx context.Context, uri string) ( } did, collection, rkey := parts[0], parts[1], parts[2] + // resolve the DID to get the PDS + did, svc, _, err := resolveRepoService(ctx, did) + if err != nil { + return nil, echo.NewHTTPError(http.StatusBadRequest, "failed to resolve DID") + } + params := url.Values{} params.Set("repo", did) params.Set("collection", collection) params.Set("rkey", rkey) - reqURL := s.cli.GamesAPIURL + "/xrpc/com.atproto.repo.getRecord?" + params.Encode() + reqURL := svc + "/xrpc/com.atproto.repo.getRecord?" + params.Encode() req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil) if err != nil { -- 2.51.2