@@ -22,6 +22,7 @@ Hathora Cloud API: Welcome to the Hathora Cloud API documentation! Learn how to
2222 * [ Error Handling] ( #error-handling )
2323 * [ Server Selection] ( #server-selection )
2424 * [ Authentication] ( #authentication )
25+ * [ Debugging] ( #debugging )
2526
2627<!-- End Table of Contents [toc] -->
2728
@@ -36,15 +37,15 @@ The samples below show how a published SDK artifact is used:
3637
3738Gradle:
3839``` groovy
39- implementation 'dev.hathora:cloud-sdk:3.1.10 '
40+ implementation 'dev.hathora:cloud-sdk:3.2.0 '
4041```
4142
4243Maven:
4344``` xml
4445<dependency >
4546 <groupId >dev.hathora</groupId >
4647 <artifactId >cloud-sdk</artifactId >
47- <version >3.1.10 </version >
48+ <version >3.2.0 </version >
4849</dependency >
4950```
5051
@@ -61,29 +62,6 @@ On Windows:
6162``` bash
6263gradlew.bat publishToMavenLocal -Pskip.signing
6364```
64-
65- ### Logging
66- A logging framework/facade has not yet been adopted but is under consideration.
67-
68- For request and response logging (especially json bodies) use:
69- ``` java
70- SpeakeasyHTTPClient . setDebugLogging(true ); // experimental API only (may change without warning)
71- ```
72- Example output:
73- ```
74- Sending request: http://localhost:35123/bearer#global GET
75- Request headers: {Accept=[application/json], Authorization=[******], Client-Level-Header=[added by client], Idempotency-Key=[some-key], x-speakeasy-user-agent=[speakeasy-sdk/java 0.0.1 internal 0.1.0 org.openapis.openapi]}
76- Received response: (GET http://localhost:35123/bearer#global) 200
77- Response headers: {access-control-allow-credentials=[true], access-control-allow-origin=[*], connection=[keep-alive], content-length=[50], content-type=[application/json], date=[Wed, 09 Apr 2025 01:43:29 GMT], server=[gunicorn/19.9.0]}
78- Response body:
79- {
80- "authenticated": true,
81- "token": "global"
82- }
83- ```
84- WARNING: This should only used for temporary debugging purposes. Leaving this option on in a production system could expose credentials/secrets in logs. <i >Authorization</i > headers are redacted by default and there is the ability to specify redacted header names via ` SpeakeasyHTTPClient.setRedactedHeaders ` .
85-
86- Another option is to set the System property ` -Djdk.httpclient.HttpClient.log=all ` . However, this second option does not log bodies.
8765<!-- End SDK Installation [installation] -->
8866
8967<!-- Start SDK Example Usage [usage] -->
@@ -105,15 +83,14 @@ public class Application {
10583 public static void main (String [] args ) throws ApiError , ApiError , Exception {
10684
10785 HathoraCloud sdk = HathoraCloud . builder()
86+ .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
10887 .security(Security . builder()
109- .hathoraDevToken(" <YOUR_BEARER_TOKEN_HERE> " )
88+ .hathoraDevToken(System . getenv() . getOrDefault( " HATHORA_DEV_TOKEN " , " " ) )
11089 .build())
111- .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
112- .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
11390 .build();
11491
11592 CreateAppResponse res = sdk. appsV2(). createApp()
116- .appConfig( AppConfig . builder()
93+ .createAppConfig( CreateAppConfig . builder()
11794 .appName(" minecraft" )
11895 .authConfiguration(AuthConfiguration . builder()
11996 .build())
@@ -368,15 +345,15 @@ public class Application {
368345 public static void main (String [] args ) throws ApiError , ApiError , Exception {
369346
370347 HathoraCloud sdk = HathoraCloud . builder()
348+ .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
349+ .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
371350 .security(Security . builder()
372- .hathoraDevToken(" <YOUR_BEARER_TOKEN_HERE> " )
351+ .hathoraDevToken(System . getenv() . getOrDefault( " HATHORA_DEV_TOKEN " , " " ) )
373352 .build())
374- .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
375- .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
376353 .build();
377354
378355 CreateAppResponse res = sdk. appsV2(). createApp()
379- .appConfig( AppConfig . builder()
356+ .createAppConfig( CreateAppConfig . builder()
380357 .appName(" minecraft" )
381358 .authConfiguration(AuthConfiguration . builder()
382359 .build())
@@ -420,15 +397,14 @@ public class Application {
420397 public static void main (String [] args ) throws ApiError , ApiError , Exception {
421398
422399 HathoraCloud sdk = HathoraCloud . builder()
400+ .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
423401 .security(Security . builder()
424- .hathoraDevToken(" <YOUR_BEARER_TOKEN_HERE> " )
402+ .hathoraDevToken(System . getenv() . getOrDefault( " HATHORA_DEV_TOKEN " , " " ) )
425403 .build())
426- .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
427- .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
428404 .build();
429405
430406 CreateAppResponse res = sdk. appsV2(). createApp()
431- .appConfig( AppConfig . builder()
407+ .createAppConfig( CreateAppConfig . builder()
432408 .appName(" minecraft" )
433409 .authConfiguration(AuthConfiguration . builder()
434410 .build())
@@ -472,15 +448,14 @@ public class Application {
472448
473449 HathoraCloud sdk = HathoraCloud . builder()
474450 .serverIndex(1 )
451+ .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
475452 .security(Security . builder()
476- .hathoraDevToken(" <YOUR_BEARER_TOKEN_HERE> " )
453+ .hathoraDevToken(System . getenv() . getOrDefault( " HATHORA_DEV_TOKEN " , " " ) )
477454 .build())
478- .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
479- .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
480455 .build();
481456
482457 CreateAppResponse res = sdk. appsV2(). createApp()
483- .appConfig( AppConfig . builder()
458+ .createAppConfig( CreateAppConfig . builder()
484459 .appName(" minecraft" )
485460 .authConfiguration(AuthConfiguration . builder()
486461 .build())
@@ -512,15 +487,14 @@ public class Application {
512487
513488 HathoraCloud sdk = HathoraCloud . builder()
514489 .serverURL(" https://api.hathora.dev" )
490+ .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
515491 .security(Security . builder()
516- .hathoraDevToken(" <YOUR_BEARER_TOKEN_HERE> " )
492+ .hathoraDevToken(System . getenv() . getOrDefault( " HATHORA_DEV_TOKEN " , " " ) )
517493 .build())
518- .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
519- .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
520494 .build();
521495
522496 CreateAppResponse res = sdk. appsV2(). createApp()
523- .appConfig( AppConfig . builder()
497+ .createAppConfig( CreateAppConfig . builder()
524498 .appName(" minecraft" )
525499 .authConfiguration(AuthConfiguration . builder()
526500 .build())
@@ -562,14 +536,13 @@ public class Application {
562536
563537 HathoraCloud sdk = HathoraCloud . builder()
564538 .security(Security . builder()
565- .hathoraDevToken(" <YOUR_BEARER_TOKEN_HERE> " )
539+ .hathoraDevToken(System . getenv() . getOrDefault( " HATHORA_DEV_TOKEN " , " " ) )
566540 .build())
567- .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
568541 .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
569542 .build();
570543
571544 CreateAppResponse res = sdk. appsV2(). createApp()
572- .appConfig( AppConfig . builder()
545+ .createAppConfig( CreateAppConfig . builder()
573546 .appName(" minecraft" )
574547 .authConfiguration(AuthConfiguration . builder()
575548 .build())
@@ -601,7 +574,6 @@ public class Application {
601574
602575 HathoraCloud sdk = HathoraCloud . builder()
603576 .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
604- .orgId(" org-6f706e83-0ec1-437a-9a46-7d4281eb2f39" )
605577 .build();
606578
607579 CreateLobbyRequest req = CreateLobbyRequest . builder()
@@ -610,15 +582,14 @@ public class Application {
610582 .visibility(LobbyVisibility . PRIVATE )
611583 .roomConfig(" {\" name\" :\" my-room\" }" )
612584 .build())
613- .appId(" app-af469a92-5b45-4565-b3c4-b79878de67d2" )
614585 .roomId(" 2swovpy1fnunu" )
615586 .shortCode(" LFG4" )
616587 .build();
617588
618589 CreateLobbyResponse res = sdk. lobbiesV3(). createLobby()
619590 .request(req)
620591 .security(CreateLobbySecurity . builder()
621- .playerAuth(" <YOUR_BEARER_TOKEN_HERE> " )
592+ .playerAuth(System . getenv() . getOrDefault( " PLAYER_AUTH " , " " ) )
622593 .build())
623594 .call();
624595
@@ -630,6 +601,37 @@ public class Application {
630601```
631602<!-- End Authentication [security] -->
632603
604+ <!-- Start Debugging [debug] -->
605+ ## Debugging
606+
607+ ### Debug
608+ You can setup your SDK to emit debug logs for SDK requests and responses.
609+
610+ For request and response logging (especially json bodies), call ` enableHTTPDebugLogging(boolean) ` on the SDK builder like so:
611+ ``` java
612+ SDK . builder()
613+ .enableHTTPDebugLogging(true )
614+ .build();
615+ ```
616+ Example output:
617+ ```
618+ Sending request: http://localhost:35123/bearer#global GET
619+ Request headers: {Accept=[application/json], Authorization=[******], Client-Level-Header=[added by client], Idempotency-Key=[some-key], x-speakeasy-user-agent=[speakeasy-sdk/java 0.0.1 internal 0.1.0 org.openapis.openapi]}
620+ Received response: (GET http://localhost:35123/bearer#global) 200
621+ Response headers: {access-control-allow-credentials=[true], access-control-allow-origin=[*], connection=[keep-alive], content-length=[50], content-type=[application/json], date=[Wed, 09 Apr 2025 01:43:29 GMT], server=[gunicorn/19.9.0]}
622+ Response body:
623+ {
624+ "authenticated": true,
625+ "token": "global"
626+ }
627+ ```
628+ __ WARNING__ : This should only used for temporary debugging purposes. Leaving this option on in a production system could expose credentials/secrets in logs. <i >Authorization</i > headers are redacted by default and there is the ability to specify redacted header names via ` SpeakeasyHTTPClient.setRedactedHeaders ` .
629+
630+ __ NOTE__ : This is a convenience method that calls ` HTTPClient.enableDebugLogging() ` . The ` SpeakeasyHTTPClient ` honors this setting. If you are using a custom HTTP client, it is up to the custom client to honor this setting.
631+
632+ Another option is to set the System property ` -Djdk.httpclient.HttpClient.log=all ` . However, this second option does not log bodies.
633+ <!-- End Debugging [debug] -->
634+
633635<!-- Placeholder for Future Speakeasy SDK Sections -->
634636
635637### Maturity
0 commit comments