メインコンテンツまでスキップ

Extend SDKを使い始める

Last updated on April 4, 2025

Overview

The AccelByte Extend SDK is provided to help developers invoke AccelByte Gaming Services (AGS) endpoints from within their backend code, or other automation such as CI/CD pipelines. The Extend SDK is generated from AGS OpenAPI specs and provides required functions such as login, refreshing tokens, validating tokens, and retrying HTTP requests. It is easy to use so developers can focus on what they want to do instead of spending time thinking on how to invoke endpoints.

The AccelByte Extend SDK is available in multiple selected programming languages. We will show you the basics using the Extend SDK in several different languages.

Goals

In this guide you will:

  • Create an application project.
  • Add the Extend SDK as a project dependency.
  • Use the Extend SDK to invoke an AGS endpoint.
  • Run the application.

Prerequisites

In order to start on this guide, you should have:

  • Access to the AccelByte Gaming Services (AGS) (demo environment):
    • Use <your environment's domain URL> for AB_BASE_URL environment variable.
      • Example for AGS Shared Cloud customer: https://spaceshooter.prod.gamingservices.accelbyte.io
      • Example for AGS Private Cloud customer: https://dev.customer.accelbyte.io
    • Create an OAuth Client with client type Confidential.
      • Use Client ID value for AB_CLIENT_ID environment variable.
      • Use Client Secret value for AB_CLIENT_SECRET environment variable.
  • AccelByte Python Extend SDK
  • Access to the following tools:
    • Git
    • Python 3.10
    • Python IDE

Create a project

Create a new solution and a new console project inside the solution using the dotnet CLI.

$ mkdir -p /path/to/mysolution
$ cd /path/to/mysolution
$ dotnet new sln --name mysolution # Create a new solution: mysolution
$ dotnet new console -o myproject # Create a new console project myproject
$ dotnet sln add myproject/myproject.csproj # Add myproject to mysolution

Add to project dependency

  1. Install the SDK dependencies.

    $ pip install requests httpx websockets pyyaml
  2. Install the SDK. Replace {VERSION} with a specific release version tag, e.g. v0.74.0.

     $ pip install git+https://github.com/AccelByte/accelbyte-python-sdk.git@{VERSION}#egg=accelbyte_py_sdk
ヒント

We recommended using the Python Extend SDK version that matches your AGS version.

Use in code

  1. Create an SDK instance, log in using user credentials, and call an AccelByte Basic API in program.cs.
  2. The DefaultConfigRepository gets its values from AB_BASE_URL, AB_CLIENT_ID, and AB_CLIENT_SECRET environment variables.
using System;
using System.Collections.Generic;

using AccelByte.Sdk.Core;
using AccelByte.Sdk.Api;
using AccelByte.Sdk.Api.Legal.Model;

namespace AccelByteExample
{
internal class Program
{
static int Main(string[] args)
{
AccelByteSDK sdk = AccelByteSDK.Builder
.UseDefaultHttpClient()
.UseDefaultConfigRepository()
.UseDefaultTokenRepository()
.Build();

bool login = sdk.LoginUser("myUsername", "myPassword");
if (!login)
{
Console.WriteLine("Login failed");
return 1;
}

try
{
List<RetrieveAcceptedAgreementResponse>? response = sdk.Legal.Agreement.RetrieveAgreementsPublicOp.Execute();
if (response == null)
throw new Exception("Response is null");

foreach (var agreement in response)
Console.WriteLine(agreement.PolicyName);
}
catch (HttpResponseException e)
{
Console.WriteLine(e.Message);
return 2;
}

bool logout = sdk.Logout();
if (!logout)
{
Console.WriteLine("Logout failed");
return 1;
}

return 0;
}
}
}

Run the code

Set the required environment variables and run the code using the Python interpreter.

$ export AB_BASE_URL="<your environment's domain URL>"          # AccelByte Cloud Base URL e.g. demo environment
$ export AB_CLIENT_ID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # AccelByte Cloud OAuth Client ID
$ export AB_CLIENT_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # AccelByte Cloud OAuth Client Secret
$ python app.py

Additional resources