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

# .NET (C#) SDK Getting Started Guide

# Overview

You can use the AccelByte .NET (C#) SDK to implement our backend services within your game. The SDK acts as a bridge between your game and our services. Follow the tutorial below to learn how to set up our .NET (C#) SDK.

# Prerequisites

# Tutorials

There are two ways of integrating the SDK into your project. You can either:

  • clone the repository and then build the solution using dotnet build and AccelByte.Sdk.dll in the bin directory, or
  • after cloning the repository, you can copy the AccelByte.Sdk directory into your project, add AccelByte.Sdk.csproj into your own solution, and add it as a project reference from your project.

To use the SDK, you will need to set the following environment variables in your system or debug profile (if you are using Visual Studio):

AB_BASE_URL* AccelByte server base URL
AB_CLIENT_ID* OAuth client ID
AB_CLIENT_SECRET* OAuth client secret
AB_APP_NAME* Your app/game name. Keep it unique and short
AB_NAMESPACE* Your namespace ID
AB_TRACEID_VERSION Version of Amazon trace ID (default is 1)
AB_ENABLE_TRACEID Enable sending of Amazon trace ID on every request (default is 1). Set to 0 to disable.
AB_ENABLE_USERAGENT Enable sending user agent string for the default http client (default is 1). Set to 0 to disable.
AB_USERNAME Set the username for accessing AccelByte services
AB_PASSWORD Set the AB_USERNAME password

# Using the SDK

  1. Create an AccelByteSDK object.

    using AccelByte.Sdk.Core;
    
    AccelByteSDK sdk = AccelByteSDK.Builder
                    .UseDefaultHttpClient()
                    .UseDefaultConfigRepository()
                    .UseDefaultTokenRepository()
                    .Build();
    

The default configuration repository will load the required and optional variables from your environment. If you prefer to create your own repository, you can create a class that implements IConfigRepository and use it with the .SetConfigRepository method while creating the SDK object. You also can enable logging by calling the .EnableLog() method while creating the SDK object.

  1. Log in as a client.

    sdk.LoginClient();
    
  2. Log in as a player.

    sdk.LoginUser("<username>","<password>");
    

If you set .UseDefaultCredentialRepository or .SetCredentialRepository while creating the SDK object, you can omit the parameters for the LoginUser method.

# Import AccelByte Services

Once completed, you can use the SDK to access all available AccelByte services.

IAM

API Docs (opens new window)

using AccelByte.Sdk.Api.Iam.Model;
using AccelByte.Sdk.Api.Iam.Operation;
using AccelByte.Sdk.Api.Iam.Wrapper;
Basic

API Docs (opens new window)

using AccelByte.Sdk.Api.Basic.Model;
using AccelByte.Sdk.Api.Basic.Operation;
using AccelByte.Sdk.Api.Basic.Wrapper;
Social

API Docs (opens new window)

using AccelByte.Sdk.Api.Social.Model;
using AccelByte.Sdk.Api.Social.Operation;
using AccelByte.Sdk.Api.Social.Wrapper;
Platform

API Docs (opens new window)

using AccelByte.Sdk.Api.Platform.Model;
using AccelByte.Sdk.Api.Platform.Operation;
using AccelByte.Sdk.Api.Platform.Wrapper;
Group

API Docs (opens new window)

    using AccelByte.Sdk.Api.Group.Model;
    using AccelByte.Sdk.Api.Group.Operation;
    using AccelByte.Sdk.Api.Group.Wrapper;
Cloud Save

API Docs (opens new window)

using AccelByte.Sdk.Api.Cloudsave.Model;
using AccelByte.Sdk.Api.Cloudsave.Operation;
using AccelByte.Sdk.Api.Cloudsave.Wrapper;
DSM Controller

API Docs (opens new window)

using AccelByte.Sdk.Api.Dsmc.Model;
using AccelByte.Sdk.Api.Dsmc.Operation;
using AccelByte.Sdk.Api.Dsmc.Wrapper;
Session Browser

API Docs (opens new window)

using AccelByte.Sdk.Api.Sessionbrowser.Model;
using AccelByte.Sdk.Api.Sessionbrowser.Operation;
using AccelByte.Sdk.Api.Sessionbrowser.Wrapper;
Lobby

API Docs (opens new window)

using AccelByte.Sdk.Api.Lobby.Model;
using AccelByte.Sdk.Api.Lobby.Operation;
using AccelByte.Sdk.Api.Lobby.Wrapper;
Achievement

API Docs (opens new window)

using AccelByte.Sdk.Api.Achievement.Model;
using AccelByte.Sdk.Api.Achievement.Operation;
using AccelByte.Sdk.Api.Achievement.Wrapper;
DS Log Manager

API Docs (opens new window)

using AccelByte.Sdk.Api.Dslogmanager.Model;
using AccelByte.Sdk.Api.Dslogmanager.Operation;
using AccelByte.Sdk.Api.Dslogmanager.Wrapper;
UGC

API Docs (opens new window)

using AccelByte.Sdk.Api.Ugc.Model;
using AccelByte.Sdk.Api.Ugc.Operation;
using AccelByte.Sdk.Api.Ugc.Wrapper;
Leaderboard

API Docs (opens new window)

using AccelByte.Sdk.Api.Leaderboard.Model;
using AccelByte.Sdk.Api.Leaderboard.Operation;
using AccelByte.Sdk.Api.Leaderboard.Wrapper;
GDPR

API Docs (opens new window)

using AccelByte.Sdk.Api.Gdpr.Model;
using AccelByte.Sdk.Api.Gdpr.Operation;
using AccelByte.Sdk.Api.Gdpr.Wrapper;
Legal

API Docs (opens new window)

using AccelByte.Sdk.Api.Legal.Model;
using AccelByte.Sdk.Api.Legal.Operation;
using AccelByte.Sdk.Api.Legal.Wrapper;
Matchmaking

API Docs (opens new window)

using AccelByte.Sdk.Api.Matchmaking.Model;
using AccelByte.Sdk.Api.Matchmaking.Operation;
using AccelByte.Sdk.Api.Matchmaking.Wrapper;