Last Updated: 4/8/2022, 7:26:34 AM

# Java SDK Getting Started Guide

# Overview

You can use the AccelByte Java SDK to implement our backend services within your game. The SDK acts as a bridge between your game and our services. Follow the tutorials below to learn how to set up our Java SDK.

# Prerequisites

# Getting Started

# Installation

Add the required configuration in gradle.build. Replace {VERSION} with the specific release version tag from releases (opens new window) without the leading v character.

repositories {
   mavenCentral()
   maven {
      url 'https://nexus.accelbyte.net/repository/maven-releases/'
   }
}
dependencies {
   implementation 'net.accelbyte.sdk:sdk:{VERSION}'
}

TIP

Use the latest Java version that matches the Justice backend version.

# Logging in as a Client using the SDK

Follow the steps below to log in as the client you have just created:

  1. Create an http client instance called OkhttpClient.

  2. Create a token repository instance called DefaultConfigRepository.

  3. Create a config repository instance called DefaultTokenRepository.

  4. Create a Server SDK instance called AccelByteSDK using the http client, token repository, and config repository instances you have just created.

  5. Call the loginClient method of the AccelByteSDK Server SDK instance.

    import net.accelbyte.sdk.core.AccelByteSDK;
    import net.accelbyte.sdk.core.client.OkhttpClient;
    import net.accelbyte.sdk.core.logging.OkhttpLogger;
    import net.accelbyte.sdk.core.repository.DefaultConfigRepository;
    import net.accelbyte.sdk.core.repository.DefaultTokenRepository;OkhttpClient httpClient = new OkhttpClient();
    
    DefaultTokenRepository tokenRepository = DefaultTokenRepository.getInstance();
    
    DefaultConfigRepository configRepository = new DefaultConfigRepository();
    
    AccelByteSDK sdk = new AccelByteSDK(
    
        httpClient,
        tokenRepository,
        configRepository
    );
    
    boolean login = sdk.loginClient();
    
    if (!login) {
        // Login failed
    }
    

TIP

DefaultTokenRepository provides the necessary values for AccelByteSDK from environment variables such as AB_BASE_URL, AB_CLIENT_ID, and AB_CLIENT_SECRET.

# Available AccelByte Services

You can now start using any of the following AccelByte services in your app:

IAM

API Docs (opens new window)

import net.accelbyte.sdk.api.iam.models.*;
import net.accelbyte.sdk.api.iam.operations.*;
import net.accelbyte.sdk.api.iam.wrappers.*;
Basic

API Docs (opens new window)

import net.accelbyte.sdk.api.basic.models.*;
import net.accelbyte.sdk.api.basic.operations.*;
import net.accelbyte.sdk.api.basic.wrappers.*;
Social

API Docs (opens new window)

import net.accelbyte.sdk.api.social.models.*;
import net.accelbyte.sdk.api.social.operations.*;
import net.accelbyte.sdk.api.social.wrappers.*;
Platform

API Docs (opens new window)

import net.accelbyte.sdk.api.platform.models.*;
import net.accelbyte.sdk.api.platform.operations.*;
import net.accelbyte.sdk.api.platform.wrappers.*;
Group

API Docs (opens new window)

import net.accelbyte.sdk.api.group.models.*;
import net.accelbyte.sdk.api.group.operations.*;
import net.accelbyte.sdk.api.group.wrappers.*;
Cloud Save

API Docs (opens new window)

import net.accelbyte.sdk.api.cloudsave.models.*;
import net.accelbyte.sdk.api.cloudsave.operations.*;
import net.accelbyte.sdk.api.cloudsave.wrappers.*;
DSM Controller

API Docs (opens new window)

import net.accelbyte.sdk.api.dsmc.models.*;
import net.accelbyte.sdk.api.dsmc.operations.*;
import net.accelbyte.sdk.api.dsmc.wrappers.*;
Session Browser

API Docs (opens new window)

import net.accelbyte.sdk.api.sessionbrowser.models.*;
import net.accelbyte.sdk.api.sessionbrowser.operations.*;
import net.accelbyte.sdk.api.sessionbrowser.wrappers.*;
Lobby

API Docs (opens new window)

import net.accelbyte.sdk.api.lobby.models.*;
import net.accelbyte.sdk.api.lobby.operations.*;
import net.accelbyte.sdk.api.lobby.wrappers.*;
Achievement

API Docs (opens new window)

import net.accelbyte.sdk.api.achievement.models.*;
import net.accelbyte.sdk.api.achievement.operations.*;
import net.accelbyte.sdk.api.achievement.wrappers.*;
DS Log Manager

API Docs (opens new window)

import net.accelbyte.sdk.api.dslogmanager.models.*;
import net.accelbyte.sdk.api.dslogmanager.operations.*;
import net.accelbyte.sdk.api.dslogmanager.wrappers.*;
UGC

API Docs (opens new window)

import net.accelbyte.sdk.api.ugc.models.*;
import net.accelbyte.sdk.api.ugc.operations.*;
import net.accelbyte.sdk.api.ugc.wrappers.*;
Leaderboard

API Docs (opens new window)

import net.accelbyte.sdk.api.leaderboard.models.*;
import net.accelbyte.sdk.api.leaderboard.operations.*;
import net.accelbyte.sdk.api.leaderboard.wrappers.*;
GDPR

API Docs (opens new window)

import net.accelbyte.sdk.api.gdpr.models.*;
import net.accelbyte.sdk.api.gdpr.operations.*;
import net.accelbyte.sdk.api.gdpr.wrappers.*;
Legal

API Docs (opens new window)

import net.accelbyte.sdk.api.legal.models.*;
import net.accelbyte.sdk.api.legal.operations.*;
import net.accelbyte.sdk.api.legal.wrappers.*;
Matchmaking

API Docs (opens new window)

import net.accelbyte.sdk.api.matchmaking.models.*;
import net.accelbyte.sdk.api.matchmaking.operations.*;
import net.accelbyte.sdk.api.matchmaking.wrappers.*;