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

Extend SDKを使い始める

Last updated on February 4, 2026

注釈:本資料はAI技術を用いて翻訳されています。

概要

この記事では、複数のサポートされているプログラミング言語でExtend SDKを使用してプロジェクトを作成する基礎をガイドします。

目標

このガイドでは、以下を行います。

  • アプリケーションプロジェクトを作成する。
  • Extend SDKをプロジェクトの依存関係として追加する。
  • Extend SDKを使用してAGSエンドポイントを呼び出す。
  • アプリケーションを実行する。

前提条件

このガイドを始めるには、以下が必要です。

  • AccelByte Gaming Services(AGS)(デモ環境)へのアクセス:
    • AB_BASE_URL環境変数に<環境のドメインURL>を使用します。
      • AGS Shared Cloudのお客様の例: https://spaceshooter.prod.gamingservices.accelbyte.io
      • AGS Private Cloudのお客様の例: https://dev.customer.accelbyte.io
    • クライアントタイプがConfidentialのOAuthクライアントを作成します。
      • AB_CLIENT_ID環境変数にClient IDの値を使用します。
      • AB_CLIENT_SECRET環境変数にClient Secretの値を使用します。
  • AccelByte Python Extend SDK
  • 以下のツールへのアクセス:
    • Git
    • Python 3.10
    • Python IDE

プロジェクトを作成する

dotnet CLIを使用して、新しいソリューションとソリューション内に新しいコンソールプロジェクトを作成します。

$ mkdir -p /path/to/mysolution
$ cd /path/to/mysolution
$ dotnet new sln --name mysolution # 新しいソリューションを作成: mysolution
$ dotnet new console -o myproject # 新しいコンソールプロジェクトmyprojectを作成
$ dotnet sln add myproject/myproject.csproj # mysolutionにmyprojectを追加

プロジェクトの依存関係に追加する

  1. SDK依存関係をインストールします。

    $ pip install requests httpx websockets pyyaml
  2. SDKをインストールします。{VERSION}を特定のリリースバージョンタグ(例:v0.74.0)に置き換えます。

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

AGSバージョンと一致するPython Extend SDKバージョンを使用することをお勧めします。

コードで使用する

  1. program.csでSDKインスタンスを作成し、ユーザー認証情報を使用してログインし、AccelByte Basic APIを呼び出します。
  2. DefaultConfigRepositoryAB_BASE_URLAB_CLIENT_IDAB_CLIENT_SECRET環境変数から値を取得します。
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;
}
}
}

コードを実行する

必要な環境変数を設定し、Pythonインタープリタを使用してコードを実行します。

$ export AB_BASE_URL="<環境のドメインURL>"          # AccelByte CloudベースURL(例:デモ環境)
$ export AB_CLIENT_ID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # AccelByte Cloud OAuth Client ID
$ export AB_CLIENT_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # AccelByte Cloud OAuth Client Secret
$ python app.py

追加リソース