{"id":29572671,"url":"https://github.com/accelbyte/accelbyte-java-sdk","last_synced_at":"2026-04-02T21:20:32.373Z","repository":{"id":37583258,"uuid":"442335756","full_name":"AccelByte/accelbyte-java-sdk","owner":"AccelByte","description":"Java Extend SDK generated from AccelByte Gaming Services OpenAPI specification","archived":false,"fork":false,"pushed_at":"2026-04-01T08:13:43.000Z","size":31859,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-01T10:23:13.022Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AccelByte.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-28T03:15:18.000Z","updated_at":"2026-04-01T08:13:51.000Z","dependencies_parsed_at":"2022-07-12T16:25:00.892Z","dependency_job_id":"1e2a8693-16c9-43b7-8014-cb8d400e2164","html_url":"https://github.com/AccelByte/accelbyte-java-sdk","commit_stats":null,"previous_names":[],"tags_count":85,"template":false,"template_full_name":null,"purl":"pkg:github/AccelByte/accelbyte-java-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-java-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-java-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-java-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-java-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AccelByte","download_url":"https://codeload.github.com/AccelByte/accelbyte-java-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelByte%2Faccelbyte-java-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31316570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-19T05:10:50.594Z","updated_at":"2026-04-02T21:20:32.365Z","avatar_url":"https://github.com/AccelByte.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AccelByte Java SDK\n\nA software development kit (SDK) for interacting with AccelByte services written in Java.\n\nThis SDK was generated from OpenAPI spec included in the [spec](spec) directory.\n\n## Setup\n\nThis SDK is developed using JDK 8 and Gradle 7.5.\n\n### Gradle\n\nAdd the required configuration in `gradle.build`. Replace `{VERSION}` with \na specific release version tag from [releases](https://github.com/AccelByte/accelbyte-java-sdk/releases) \nwithout the leading `v` character.\n\n#### For v0.18.0 and later\n\nThe artifacts are published in Maven Central.\n\n```java\nrepositories {\n   mavenCentral()\n}\n\ndependencies {\n   implementation 'net.accelbyte.sdk:sdk:{VERSION}'\n}\n```\n\n#### For v0.17.0 and earlier\n\nThe artifacts are moved to AccelByte Internal Nexus. You need to request for `{USERNAME}` and `{PASSWORD}` to be able to access it.\n\n```java\nrepositories {\n   mavenCentral()\n   maven {\n      url 'https://nexus.tools.accelbyte.net/repository/maven-releases/'\n      credentials {\n         username = '{USERNAME}'\n         password = '{PASSWORD}'\n      }\n   }\n}\n\ndependencies {\n   implementation 'net.accelbyte.sdk:sdk:{VERSION}'\n}\n```\n\n### Environment Variables\n\nThe following environment variables need to be set when using `DefaultConfigRepository`.\n\n| Name               | Required                                              | Example                          |\n|--------------------|-------------------------------------------------------|----------------------------------|\n| `AB_BASE_URL`      | Yes                                                   | https://test.accelbyte.io        |\n| `AB_CLIENT_ID`     | Yes                                                   | abcdef0123456789abcdef0123456789 |\n| `AB_CLIENT_SECRET` | Yes, but only if you use a confidential `AB_CLIENT_ID`| ab#c,d)ef(ab#c,d)ef(ab#c,d)ef(ab |\n\n## Usage\n\n### Instantiation\n\n#### With Default HTTP Client (OkhttpClient)\n\nUse the following to get SDK instance with basic HTTP functionality.\n    \n```java\nAccelByteConfig config = new AccelByteConfig(\n      new OkhttpClient(),\n      DefaultTokenRepository.getInstance(),\n      new DefaultConfigRepository());     // Using DefaultConfigRepository, make sure the required environment variables are set\n\nAccelByteSDK sdk = new AccelByteSDK(config);\n```\n\n#### With Reliable HTTP client\n\nUse the following to get SDK instance with HTTP retry functionality.\n\n```java\nfinal DefaultHttpRetryPolicy retryPolicy = new DefaultHttpRetryPolicy();\n\nretryPolicy.setCallTimeout(3000);   // In milliseconds\nretryPolicy.setMaxRetry(3);\nretryPolicy.setRetryInterval(2000);    // In milliseconds\nretryPolicy.setRetryIntervalType(RetryIntervalType.LINEAR);    // LINEAR, EXPONENTIAL are available\n\nprivate final ReliableHttpClient reliableHttpClient = new ReliableHttpClient(retryPolicy);\n\nAccelByteConfig config = new AccelByteConfig(\n      reliableHttpClient,\n      DefaultTokenRepository.getInstance(),\n      new DefaultConfigRepository());     // Using DefaultConfigRepository, make sure the required environment variables are set\n\nAccelByteSDK sdk = new AccelByteSDK(config);\n```\n\n#### Automatic Token Refresh\n\nUse the following to get SDK instance with automatic token refresh which is checked and performed periodically.\n\n```java\nAccelByteConfig config =  AccelByteConfig.getDefault() //use default configuration\n   .useBackgroundTokenRefresh(); // use background token refresh.\n\n//use configuration object when creating the sdk object.\nAccelByteSDK sdk = new AccelByteSDK(config);\n```\n\nTo configure background token refresh, set the following environment variables.\n\n| Name                             | Required | Description                                                                                    |\n|----------------------------------|--------- |------------------------------------------------------------------------------------------------|\n| `AB_REFRESH_RATE`                | No       | Fraction of token lifetime before it is refreshed. Value between`0.0` to `1.0`. Default: `0.8` |\n| `AB_REFRESH_MAX_RETRY`           | No       | Maximum number of retries for refresh token requests before failing. Default: `2`              |\n| `AB_REFRESH_BACKGROUND_INTERVAL` | No       | Timer interval (in seconds) to check token expiry. Default: `10`                               |\n| `AB_REFRESH_BACKGROUND_ENABLED`  | No       | Enables background token refresh. Default: `true`                                              |\n\nNOTE: The `AB_REFRESH_RATE` uses a float value between `0` and `1` representing the fraction of the token's lifetime. For example, if a token is valid for 1 hour (3600 seconds), and `AB_REFRESH_RATE` is set to `0.5`, the SDK will attempt to refresh the token after it has less than 1800 seconds remaining (3600 x 0.5).\n\nBackground token refresh runs on a timer at a specified interval to check for token expiry. If the token is nearing its expiration time (as determined by the `AB_REFRESH_RATE` value), it will be refreshed automatically.\n\nIf a periodic background process is not preferred, use .useOnDemandTokenRefresh() instead. This method triggers automatic token refresh whenever the SDK calls any AGS endpoint.\nPlease note that this type of token refresh is recommended only for OAuth client logins (using the LoginClient method), as it relies solely on the configured client ID and client secret values. It can be used for other login types, but once the refresh token expires, any subsequent calls will be unauthorized.\n    \n```java\nAccelByteConfig config =  AccelByteConfig.getDefault() //use default configuration\n   .useOnDemandTokenRefresh(); // use on-demand token refresh.\n\n//use configuration object when creating the sdk object.\nAccelByteSDK sdk = new AccelByteSDK(config);\n```\n\nTo configure on-demand token refresh, set the following environment variables.\n\n| Name                          | Required | Description                                                                                    |\n|-------------------------------|--------- |------------------------------------------------------------------------------------------------|\n| `AB_REFRESH_RATE`             | No       | Fraction of token lifetime before it is refreshed. Value between`0.0` to `1.0`. Default: `0.8` |\n| `AB_REFRESH_MAX_RETRY`        | No       | Maximum number of retries for refresh token requests before failing. Default: `2`              |\n| `AB_REFRESH_ONDEMAND_ENABLED` | No       | Enables token refresh. Default: `true`                                                         |\n\nNOTE: Avoid using both `.useOnDemandTokenRefresh()` and `.useBackgroundTokenRefresh()` together, as it introduces unnecessary overhead and may lead to unexpected behavior.\n\nInstantiating the SDK object by assigning a `DefaultTokenRefreshRepository` directly is not recommended, but it still works with the default behavior set to on-demand token refresh.\n```java\nAccelByteConfig config = new AccelByteConfig(\n   new OkhttpClient(),\n   new DefaultTokenRefreshRepository();   // Using DefaultTokenRefreshRepository which implements TokenRefresh interface to enable automatic token refresh\n   new DefaultConfigRepository());     // Using DefaultConfigRepository, make sure the required environment variables are set\n\nAccelByteSDK sdk = new AccelByteSDK(config);\n```\n\n#### Local Token Validation\n\nTo enable local token validation, use the following when instantiating the SDK. When enabled, the SDK instance will cache JWKS and revocation list for performing token validation so that it does not have to call AccelByte Gaming Services endpoint each time. See [Validate Access Token](#validate-access-token) section on how to validate token using SDK.\n\n```java\nfinal DefaultConfigRepository defaultConfigRepository = new DefaultConfigRepository();    // Using DefaultConfigRepository, make sure the required environment variables are set\n\ndefaultConfigRepository.setLocalTokenValidationEnabled(true);     // Enable local token validation\ndefaultConfigRepository.setJwksRefreshInterval(300);    // Refresh JWKS for local token validation every 5 minutes\ndefaultConfigRepository.setRevocationListRefreshInterval(300);    // Refresh revocation list for local token validation every 5 minutes\n\nAccelByteConfig config = new AccelByteConfig(\n      new OkhttpClient(),\n      DefaultTokenRepository.getInstance(),\n      defaultConfigRepository);\n\nAccelByteSDK sdk = new AccelByteSDK(config);\n```\n\n### Login\n\n#### Login Using Username and Password\n\n```java\nboolean login = sdk.loginUser(\"myUsername\", \"myPassword\");\n\nif (!login) {\n    // Login failed  \n}\n```\n\n#### Login Using Username and Password with Specific Scope\n\n```java\nboolean login = sdk.loginUser(\"myUsername\", \"myPassword\", \"scopeA scopeB\");   // Space separated scope values\n\nif (!login) {\n    // Login failed  \n}\n```\n\n#### Login Using OAuth Client\n\n```java\nboolean login = sdk.loginClient();\n\nif (!login) {\n    // Login failed   \n}\n```\n\n\u003e :warning: **Please use loginClient() function with confidential OAuth client:** Using loginClient() function with public OAuth client is not supported.\n\n### Validate Access Token\n\nTo validate if an access token is valid and has the required permission, use the `ValidateToken` method of `AccelByteSDK` instance. To validate an access token without validating the required permission, omit the optional `permission` and `action` parameters of `ValidateToken` method. By default, remote token validation is performed. However, if higher throughput is required, you may enable local token validation as mentioned in [Local Token Validation](#local-token-validation) section. With local token validation, token validation will be quicker at the expense of delayed revocation list update (a revoked token may still be regarded as valid until local cache of the revocation list is updated).\n\n```java\nboolean isOk = sdk.validateToken(\"token\", \"ADMIN:NAMESPACE:serversdktest:INFORMATION:USER:abdedef\", 2);  // Validate token\n\nif (isOk) {\n    // Token is valid and has the required permission\n}\nelse {\n   // Token is not valid or expired or does not have the required permission\n}\n```\n\n### Parse Access Token\n\nUse the following to parse access token and get its payload.\n```java\nAccessTokenPayload payload = sdk.parseAccessToken(\"access token\", false);\n\n// Or if token validation is required before parsing, then use the following\n\nAccessTokenPayload payload = sdk.parseAccessToken(\"access token\", true);\n```\nThe `payload` will be null if the parse failed or when validation is required, and it failed.\n\n\n### Interacting with a Service Endpoint\n\nAs an example, we will get current user profile info using [getMyProfileInfo](https://docs.accelbyte.io/api-explorer/#Basic/getMyProfileInfo) endpoint available in [basic](https://docs.accelbyte.io/api-explorer/#Basic) service.\n\n```java\n// Login using username and password\n\nboolean login = sdk.loginUser(\"myUsername\", \"myPassword\");\n\nif (!login) {\n      System.out.println(\"login failed\");\n      return;\n}\n\n// Instantiate UserProfile wrapper class which is part of basic service\n\nUserProfile userProfile = new UserProfile(sdk);\n\ntry {\n   // Make a call to getMyProfileInfo endpoint\n   UserProfilePrivateInfo response = userProfile\n         .getMyProfileInfo(new GetMyProfileInfo(\"accelbyte\"));\n\n   System.out.println(response.getUserId());    // Success response\n\n} catch (HttpResponseException e) {     // Error response from the service\n   e.printStackTrace();\n\n   if (e.getHttpCode() == 400) {\n      // Handle specific error response HTTP code\n   }\n\n} catch (IOException e) {     // Network error\n   e.printStackTrace();    \n}\n```\n\n### Refresh Token Manually\n\n```java\nboolean isOk = sdk.refreshToken();  // Trigger token refresh manually when not using automatic token refresh functionality\n\nif (isOk) {\n    // Refresh token is succesful or not required\n}\nelse {\n   // Refresh token failed\n}\n```\n\n### Logout\n\n```java\nboolean logout = sdk.logout();\n\nif (!logout) {\n    // Logout failed\n}\n```\n\n### Websocket\n- **Automatic Ping Interval:** by default, automatic ping frames are not sent.  \n\n    To enable the feature, for the LobbyWebSocketClient.create() call, simply pass in:\n    - `pingIntervalMs` \u003e 0 to set the number of seconds between each automatic ping (until the connection is closed) \n    - `pingIntervalMs` = 0 means disabled\n\n- **Websocket Reconnection:**  Websocket Reconnection is a feature to help support auto-reconnection on websocket disconnects resulting from RFC 6455 status codes between 1001 to 2999. By default, the feature is off.  \n\n    To enable the feature, for the LobbyWebSocketClient.create() call, simply pass in: \n    - `reconnectDelayMs` \u003e 0 to control the delay between each reconnect attempt (with exponential backoff)  \n    - `reconnectDelayMs` = 0 means disabled\n    - `maxNumReconnectAttempts` to control the maximum number of reconnection attempts\n    - `maxNumReconnectAttempts` = -1 means unlimited reconnect attempts (`reconnectDelayMs` must be \u003e 0 to enable)\n\nExample:\n```java\nfinal WebSocketListener listener =\n    new WebSocketListener() {\n        @Override\n        public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) {\n            log.info(\"Received onMessage: \" + text);\n            ...\n        }\n    };\n\nfinal int RECONNECT_DELAY_MS = 60000;  // 1m (0 to disable)\nfinal int MAX_NUM_RECONNECT_ATTEMPTS = 10; // -1 for unlimited reconnect attempts (RECONNECT_DELAY_MS must be \u003e 0 to enable)\n\nfinal int PING_INTERVAL_MS = 30000;  // 30s (0 to disable)\n\nfinal LobbyWebSocketClient ws =\n        LobbyWebSocketClient.create(\n            new DefaultConfigRepository(), DefaultTokenRepository.getInstance(), listener, RECONNECT_DELAY_MS, MAX_NUM_RECONNECT_ATTEMPTS, PING_INTERVAL_MS);\n\nws.connect();\n\nfinal String requestMessage = PartyCreateRequest.builder().id(request_id).build().toWSM();\nws.sendMessage(requestMessage);\n...\n```\n**Lobby session preservation logic upon reconnect:**\nIn the event of a disconnection and a reconnection, the previous lobby session id will be requested for reuse via the \"X-Ab-LobbySessionID\" header with the cached value from the previous lobby session.\n## Samples\n\nSample apps are available in the [samples](samples) directory.\n\n## Documentation\n\nReference about AccelByte service endpoints and their corresponding SDK API is available in [docs/operations](docs/operations) directory.\n\nFor more information on how to use AccelByte services and SDKs, see [docs.accelbyte.io](https://docs.accelbyte.io/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccelbyte%2Faccelbyte-java-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faccelbyte%2Faccelbyte-java-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccelbyte%2Faccelbyte-java-sdk/lists"}