Class SessionServiceClient

java.lang.Object
com.hypixel.hytale.server.core.auth.SessionServiceClient

public class SessionServiceClient extends Object
HTTP client for communicating with the Session Service API.
  • Constructor Details

    • SessionServiceClient

      public SessionServiceClient(@Nonnull String sessionServiceUrl)
      Creates a new Session Service client.
      Parameters:
      sessionServiceUrl - The base URL of the Session Service
  • Method Details

    • requestAuthorizationGrantAsync

      public CompletableFuture<String> requestAuthorizationGrantAsync(@Nonnull String identityToken, @Nonnull String serverAudience, @Nonnull String bearerToken)
      Requests an authorization grant from the Session Service for a joining player. POST /server-join/auth-grant

      Uses the player's identity token for validation instead of just the UUID.

      Parameters:
      identityToken - The player's identity token
      serverAudience - The server identifier for the JWT audience claim
      bearerToken - The server's session token for authentication
      Returns:
      CompletableFuture with the authorization grant, or null if request fails
    • exchangeAuthGrantForTokenAsync

      public CompletableFuture<String> exchangeAuthGrantForTokenAsync(@Nonnull String authorizationGrant, @Nonnull String x509Fingerprint, @Nonnull String bearerToken)
      Exchanges an authorization grant for a JWT access token. POST /server-join/auth-token

      This is used by the server to exchange its auth grant (provided by client) for a cert-bound access token.

      Parameters:
      authorizationGrant - The authorization grant from Session Service
      x509Fingerprint - The server's certificate fingerprint for cert binding
      bearerToken - The server's session/identity token for authentication
      Returns:
      CompletableFuture with the access token, or null if request fails
    • getJwks

      @Nullable public SessionServiceClient.JwksResponse getJwks()
      Fetches the JWKS (JSON Web Key Set) from the Session Service. GET /.well-known/jwks.json
      Returns:
      The JWKS response, or null if request fails
    • getGameProfiles

      @Nullable public SessionServiceClient.GameProfile[] getGameProfiles(@Nonnull String oauthAccessToken)
      Fetches the user's game profiles from the Account Data service. GET /my-account/get-profiles
      Parameters:
      oauthAccessToken - The OAuth access token
      Returns:
      Array of game profiles, or null if request fails
    • createGameSession

      @Nullable public SessionServiceClient.GameSessionResponse createGameSession(@Nonnull String oauthAccessToken, @Nonnull UUID profileUuid)
      Creates a new game session using an OAuth access token. POST /game-session/new
      Parameters:
      oauthAccessToken - The OAuth access token (used as bearer auth)
      profileUuid - The game profile UUID to create the session for
      Returns:
      The created game session, or null if request fails
    • refreshSessionAsync

      public CompletableFuture<SessionServiceClient.GameSessionResponse> refreshSessionAsync(@Nonnull String sessionToken)
      Refreshes the current game session to obtain new tokens. POST /game-session/refresh

      The returned future completes with null if the server rejected the request (non-retryable), or completes exceptionally with IOException on transient IO errors (retryable).

      Parameters:
      sessionToken - The current session token (used as bearer auth)
      Returns:
      CompletableFuture with the refreshed session, or null if the server rejected the request
    • terminateSession

      public void terminateSession(@Nonnull String sessionToken)
      Terminates the current game session. DELETE /game-session
      Parameters:
      sessionToken - The session token (used as bearer auth)