Contents
Class SessionServiceClient
java.lang.Object
com.hypixel.hytale.server.core.auth.SessionServiceClient
HTTP client for communicating with the Session Service API.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResponse from /server-join/auth-tokenstatic classResponse from /server-join/auth-grantstatic classGame profile from Account Data servicestatic classResponse from POST /game-session/refresh and POST /game-session/childstatic classIndividual key in JWKSstatic classResponse from /.well-known/jwks.jsonstatic classResponse from GET /my-account/get-launcher-data -
Constructor Summary
ConstructorsConstructorDescriptionSessionServiceClient(String sessionServiceUrl) Creates a new Session Service client. -
Method Summary
Modifier and TypeMethodDescriptioncreateGameSession(String oauthAccessToken, UUID profileUuid) Creates a new game session using an OAuth access token.exchangeAuthGrantForTokenAsync(String authorizationGrant, String x509Fingerprint, String bearerToken) Exchanges an authorization grant for a JWT access token.getGameProfiles(String oauthAccessToken) Fetches the user's game profiles from the Account Data service.getJwks()Fetches the JWKS (JSON Web Key Set) from the Session Service.refreshSessionAsync(String sessionToken) Refreshes the current game session to obtain new tokens.requestAuthorizationGrantAsync(String identityToken, String serverAudience, String bearerToken) Requests an authorization grant from the Session Service for a joining player.voidterminateSession(String sessionToken) Terminates the current game session.
-
Constructor Details
-
SessionServiceClient
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-grantUses the player's identity token for validation instead of just the UUID.
- Parameters:
identityToken- The player's identity tokenserverAudience- The server identifier for the JWT audience claimbearerToken- 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-tokenThis 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 Servicex509Fingerprint- The server's certificate fingerprint for cert bindingbearerToken- The server's session/identity token for authentication- Returns:
- CompletableFuture with the access token, or null if request fails
-
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/refreshThe returned future completes with null if the server rejected the request (non-retryable), or completes exceptionally with
IOExceptionon 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
Terminates the current game session. DELETE /game-session- Parameters:
sessionToken- The session token (used as bearer auth)
-